@@ -274,6 +274,31 @@ export function main() {
274274 } ) ;
275275 } ) ) ;
276276
277+ it ( 'should allow specifying directives as bindings' , inject ( [ TestBed , AsyncTestCompleter ] , ( tb , async ) => {
278+ tb . overrideView ( MyComp , new View ( {
279+ template : '<child-cmp></child-cmp>' ,
280+ directives : [ bind ( ChildComp ) . toClass ( ChildComp ) ]
281+ } ) ) ;
282+
283+ tb . createView ( MyComp , { context : ctx } ) . then ( ( view ) => {
284+ view . detectChanges ( ) ;
285+
286+ expect ( view . rootNodes ) . toHaveText ( 'hello' ) ;
287+ async . done ( ) ;
288+ } ) ;
289+ } ) ) ;
290+
291+ it ( 'should read directives metadata from their binding token' , inject ( [ TestBed , AsyncTestCompleter ] , ( tb , async ) => {
292+ tb . overrideView ( MyComp , new View ( {
293+ template : '<div public-api><div needs-public-api></div></div>' ,
294+ directives : [ bind ( PublicApi ) . toClass ( PrivateImpl ) , NeedsPublicApi ]
295+ } ) ) ;
296+
297+ tb . createView ( MyComp , { context : ctx } ) . then ( ( view ) => {
298+ async . done ( ) ;
299+ } ) ;
300+ } ) ) ;
301+
277302 it ( 'should support template directives via `<template>` elements.' , inject ( [ TestBed , AsyncTestCompleter ] , ( tb , async ) => {
278303 tb . overrideView ( MyComp ,
279304 new View ( {
@@ -1191,3 +1216,24 @@ class NeedsAttribute {
11911216 this . fooAttribute = fooAttribute ;
11921217 }
11931218}
1219+
1220+ @Decorator ( {
1221+ selector : '[public-api]'
1222+ } )
1223+ class PublicApi {
1224+ }
1225+
1226+ @Decorator ( {
1227+ selector : '[private-impl]'
1228+ } )
1229+ class PrivateImpl extends PublicApi {
1230+ }
1231+
1232+ @Decorator ( {
1233+ selector : '[needs-public-api]'
1234+ } )
1235+ class NeedsPublicApi {
1236+ constructor ( @Parent ( ) api :PublicApi ) {
1237+ expect ( api instanceof PrivateImpl ) . toBe ( true ) ;
1238+ }
1239+ }
0 commit comments