@@ -35,6 +35,7 @@ import {
3535import {
3636 Attribute ,
3737 Query ,
38+ ViewQuery ,
3839 ComponentMetadata ,
3940 DirectiveMetadata ,
4041 LifecycleEvent
@@ -51,9 +52,11 @@ import {QueryList} from 'angular2/src/core/compiler/query_list';
5152@IMPLEMENTS ( AppView )
5253class DummyView extends SpyObject {
5354 changeDetector ;
55+ elementOffset : number ;
5456 constructor ( ) {
5557 super ( AppView ) ;
5658 this . changeDetector = null ;
59+ this . elementOffset = 0 ;
5760 }
5861 noSuchMethod ( m ) { return super . noSuchMethod ( m ) ; }
5962}
@@ -159,6 +162,12 @@ class NeedsQuery {
159162 constructor ( @Query ( CountingDirective ) query : QueryList < CountingDirective > ) { this . query = query ; }
160163}
161164
165+ @Injectable ( )
166+ class NeedsViewQuery {
167+ query : QueryList < CountingDirective > ;
168+ constructor ( @ViewQuery ( CountingDirective ) query : QueryList < CountingDirective > ) { this . query = query ; }
169+ }
170+
162171@Injectable ( )
163172class NeedsQueryByVarBindings {
164173 query : QueryList < any > ;
@@ -850,6 +859,41 @@ export function main() {
850859 } ) ;
851860 } ) ;
852861
862+ describe ( "getRootViewInjectors" , ( ) => {
863+ it ( "should return an empty array if there is no nested view" , ( ) => {
864+ var inj = injector ( extraBindings ) ;
865+ expect ( inj . getRootViewInjectors ( ) ) . toEqual ( [ ] ) ;
866+ } ) ;
867+ } ) ;
868+
869+ describe ( "dehydrate" , ( ) => {
870+ function cycleHydrate ( inj : ElementInjector , host = null ) : void {
871+ // Each injection supports 3 query slots, so we cycle 4 times.
872+ for ( var i = 0 ; i < 4 ; i ++ ) {
873+ inj . dehydrate ( ) ;
874+ inj . hydrate ( null , host , defaultPreBuiltObjects ) ;
875+ }
876+ }
877+
878+ it ( "should handle repeated hydration / dehydration" , ( ) => {
879+ var inj = injector ( extraBindings ) ;
880+ cycleHydrate ( inj ) ;
881+ } ) ;
882+
883+ it ( "should handle repeated hydration / dehydration with query present" , ( ) => {
884+ var inj = injector ( ListWrapper . concat ( [ NeedsQuery ] , extraBindings ) ) ;
885+ cycleHydrate ( inj ) ;
886+ } ) ;
887+
888+
889+ it ( "should handle repeated hydration / dehydration with view query present" , ( ) => {
890+ var inj = injector ( extraBindings ) ;
891+ var host = injector ( ListWrapper . concat ( [ NeedsViewQuery ] , extraBindings ) ) ;
892+
893+ cycleHydrate ( inj , host ) ;
894+ } ) ;
895+ } ) ;
896+
853897 describe ( "lifecycle" , ( ) => {
854898 it ( "should call onDestroy on directives subscribed to this event" , ( ) => {
855899 var inj = injector ( ListWrapper . concat (
0 commit comments