11// make sure you import mocha-config before @angular/core
22import { Component , ElementRef , NgModule , NO_ERRORS_SCHEMA } from '@angular/core' ;
33import { TestBed } from '@angular/core/testing' ;
4- import { AndroidFilterComponent , DEVICE , IOSFilterComponent , NativeScriptModule } from '@nativescript/angular' ;
4+ import { AndroidFilterComponent , DEVICE , IOSFilterComponent , AppleFilterComponent , NativeScriptModule } from '@nativescript/angular' ;
55import { platformNames } from '@nativescript/core/platform' ;
66import { createDevice , dumpView } from './test-utils.spec' ;
77@Component ( {
@@ -15,6 +15,17 @@ export class IosSpecificComponent {
1515 constructor ( public elementRef : ElementRef ) { }
1616}
1717
18+ @Component ( {
19+ template : ` <StackLayout>
20+ <apple><Label text="Apple"></Label></apple>
21+ </StackLayout>` ,
22+ imports : [ AppleFilterComponent ] ,
23+ schemas : [ NO_ERRORS_SCHEMA ] ,
24+ } )
25+ export class AppleSpecificComponent {
26+ constructor ( public elementRef : ElementRef ) { }
27+ }
28+
1829@Component ( {
1930 template : ` <StackLayout>
2031 <android><Label text="ANDROID"></Label></android>
@@ -71,6 +82,31 @@ describe('Platform filter directives', () => {
7182 } ) ;
7283 } ) ;
7384
85+ describe ( 'on Apple device' , ( ) => {
86+ beforeEach ( ( ) => {
87+ return TestBed . configureTestingModule ( {
88+ imports : DECLARATIONS ,
89+ providers : [ { provide : DEVICE , useValue : createDevice ( platformNames . ios ) } ] ,
90+ schemas : [ NO_ERRORS_SCHEMA ] ,
91+ } ) . compileComponents ( ) ;
92+ } ) ;
93+ it ( 'does render apple specific content' , ( ) => {
94+ const fixture = TestBed . createComponent ( AppleSpecificComponent ) ;
95+ fixture . detectChanges ( ) ;
96+ const componentRef = fixture . componentRef ;
97+ const componentRoot = componentRef . instance . elementRef . nativeElement ;
98+ expect ( dumpView ( componentRoot , true ) . indexOf ( '(label[text=Apple])' ) >= 0 ) . toBe ( true ) ;
99+ } ) ;
100+ it ( 'does not render android specific content' , ( ) => {
101+ const fixture = TestBed . createComponent ( AndroidSpecificComponent ) ;
102+ fixture . detectChanges ( ) ;
103+ const componentRef = fixture . componentRef ;
104+ const componentRoot = componentRef . instance . elementRef . nativeElement ;
105+ console . log ( dumpView ( componentRoot , true ) ) ;
106+ expect ( dumpView ( componentRoot , true ) . indexOf ( 'label' ) < 0 ) . toBe ( true ) ;
107+ } ) ;
108+ } ) ;
109+
74110 describe ( 'on Android device' , ( ) => {
75111 beforeEach ( ( ) => {
76112 return TestBed . configureTestingModule ( {
0 commit comments