diff --git a/.gitignore b/.gitignore index ca784df6e..c91ed111d 100644 --- a/.gitignore +++ b/.gitignore @@ -22,11 +22,11 @@ tags npm-debug.log nativescript-angular*.tgz -tests/app/**/*.js -tests/test-output.txt -tests/platforms -tests/lib -tests/node_modules +tests/tns/app/**/*.js +tests/tns/test-output.txt +tests/tns/platforms +tests/tns/lib +tests/tns/node_modules ng-sample/app/**/*.js ng-sample/app/global.d.ts diff --git a/.travis.yml b/.travis.yml index 903364dbc..80eb2ec77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,18 +29,17 @@ install: - cd nativescript-angular - npm install - npm run tslint -- cd ../tests +- cd ../tests/tns - npm install - tns platform add android before_script: - echo no | android create avd --force -n test -t android-19 -b armeabi-v7a - emulator -memory 1024 -avd test -no-audio -no-window & script: -- -- - tns build android - android-wait-for-emulator - npm run run-appium-android +- npm run test before_deploy: - cd ../nativescript-angular - npm install -g nativescript --ignore-scripts diff --git a/tests/.ctags-exclude b/tests/tns/.ctags-exclude similarity index 100% rename from tests/.ctags-exclude rename to tests/tns/.ctags-exclude diff --git a/tests/.gitignore b/tests/tns/.gitignore similarity index 100% rename from tests/.gitignore rename to tests/tns/.gitignore diff --git a/tests/Makefile b/tests/tns/Makefile similarity index 100% rename from tests/Makefile rename to tests/tns/Makefile diff --git a/tests/README.md b/tests/tns/README.md similarity index 100% rename from tests/README.md rename to tests/tns/README.md diff --git a/tests/app/App_Resources/Android/AndroidManifest.xml b/tests/tns/app/App_Resources/Android/AndroidManifest.xml similarity index 100% rename from tests/app/App_Resources/Android/AndroidManifest.xml rename to tests/tns/app/App_Resources/Android/AndroidManifest.xml diff --git a/tests/app/App_Resources/Android/drawable-hdpi/icon.png b/tests/tns/app/App_Resources/Android/drawable-hdpi/icon.png similarity index 100% rename from tests/app/App_Resources/Android/drawable-hdpi/icon.png rename to tests/tns/app/App_Resources/Android/drawable-hdpi/icon.png diff --git a/tests/app/App_Resources/Android/drawable-ldpi/icon.png b/tests/tns/app/App_Resources/Android/drawable-ldpi/icon.png similarity index 100% rename from tests/app/App_Resources/Android/drawable-ldpi/icon.png rename to tests/tns/app/App_Resources/Android/drawable-ldpi/icon.png diff --git a/tests/app/App_Resources/Android/drawable-mdpi/icon.png b/tests/tns/app/App_Resources/Android/drawable-mdpi/icon.png similarity index 100% rename from tests/app/App_Resources/Android/drawable-mdpi/icon.png rename to tests/tns/app/App_Resources/Android/drawable-mdpi/icon.png diff --git a/tests/app/App_Resources/Android/drawable-nodpi/checkbox_checked.png b/tests/tns/app/App_Resources/Android/drawable-nodpi/checkbox_checked.png similarity index 100% rename from tests/app/App_Resources/Android/drawable-nodpi/checkbox_checked.png rename to tests/tns/app/App_Resources/Android/drawable-nodpi/checkbox_checked.png diff --git a/tests/app/App_Resources/Android/drawable-nodpi/checkbox_unchecked.png b/tests/tns/app/App_Resources/Android/drawable-nodpi/checkbox_unchecked.png similarity index 100% rename from tests/app/App_Resources/Android/drawable-nodpi/checkbox_unchecked.png rename to tests/tns/app/App_Resources/Android/drawable-nodpi/checkbox_unchecked.png diff --git a/tests/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png b/tests/tns/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png similarity index 100% rename from tests/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png rename to tests/tns/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png diff --git a/tests/app/App_Resources/iOS/Default-568h@2x.png b/tests/tns/app/App_Resources/iOS/Default-568h@2x.png similarity index 100% rename from tests/app/App_Resources/iOS/Default-568h@2x.png rename to tests/tns/app/App_Resources/iOS/Default-568h@2x.png diff --git a/tests/app/App_Resources/iOS/Default-Landscape.png b/tests/tns/app/App_Resources/iOS/Default-Landscape.png similarity index 100% rename from tests/app/App_Resources/iOS/Default-Landscape.png rename to tests/tns/app/App_Resources/iOS/Default-Landscape.png diff --git a/tests/app/App_Resources/iOS/Default-Landscape@2x.png b/tests/tns/app/App_Resources/iOS/Default-Landscape@2x.png similarity index 100% rename from tests/app/App_Resources/iOS/Default-Landscape@2x.png rename to tests/tns/app/App_Resources/iOS/Default-Landscape@2x.png diff --git a/tests/app/App_Resources/iOS/Default-Portrait.png b/tests/tns/app/App_Resources/iOS/Default-Portrait.png similarity index 100% rename from tests/app/App_Resources/iOS/Default-Portrait.png rename to tests/tns/app/App_Resources/iOS/Default-Portrait.png diff --git a/tests/app/App_Resources/iOS/Default-Portrait@2x.png b/tests/tns/app/App_Resources/iOS/Default-Portrait@2x.png similarity index 100% rename from tests/app/App_Resources/iOS/Default-Portrait@2x.png rename to tests/tns/app/App_Resources/iOS/Default-Portrait@2x.png diff --git a/tests/app/App_Resources/iOS/Default.png b/tests/tns/app/App_Resources/iOS/Default.png similarity index 100% rename from tests/app/App_Resources/iOS/Default.png rename to tests/tns/app/App_Resources/iOS/Default.png diff --git a/tests/app/App_Resources/iOS/Default@2x.png b/tests/tns/app/App_Resources/iOS/Default@2x.png similarity index 100% rename from tests/app/App_Resources/iOS/Default@2x.png rename to tests/tns/app/App_Resources/iOS/Default@2x.png diff --git a/tests/app/App_Resources/iOS/Icon-Small-50.png b/tests/tns/app/App_Resources/iOS/Icon-Small-50.png similarity index 100% rename from tests/app/App_Resources/iOS/Icon-Small-50.png rename to tests/tns/app/App_Resources/iOS/Icon-Small-50.png diff --git a/tests/app/App_Resources/iOS/Icon-Small-50@2x.png b/tests/tns/app/App_Resources/iOS/Icon-Small-50@2x.png similarity index 100% rename from tests/app/App_Resources/iOS/Icon-Small-50@2x.png rename to tests/tns/app/App_Resources/iOS/Icon-Small-50@2x.png diff --git a/tests/app/App_Resources/iOS/Icon-Small.png b/tests/tns/app/App_Resources/iOS/Icon-Small.png similarity index 100% rename from tests/app/App_Resources/iOS/Icon-Small.png rename to tests/tns/app/App_Resources/iOS/Icon-Small.png diff --git a/tests/app/App_Resources/iOS/Icon-Small@2x.png b/tests/tns/app/App_Resources/iOS/Icon-Small@2x.png similarity index 100% rename from tests/app/App_Resources/iOS/Icon-Small@2x.png rename to tests/tns/app/App_Resources/iOS/Icon-Small@2x.png diff --git a/tests/app/App_Resources/iOS/Info.plist b/tests/tns/app/App_Resources/iOS/Info.plist similarity index 100% rename from tests/app/App_Resources/iOS/Info.plist rename to tests/tns/app/App_Resources/iOS/Info.plist diff --git a/tests/app/App_Resources/iOS/checkbox_checked.png b/tests/tns/app/App_Resources/iOS/checkbox_checked.png similarity index 100% rename from tests/app/App_Resources/iOS/checkbox_checked.png rename to tests/tns/app/App_Resources/iOS/checkbox_checked.png diff --git a/tests/app/App_Resources/iOS/checkbox_unchecked.png b/tests/tns/app/App_Resources/iOS/checkbox_unchecked.png similarity index 100% rename from tests/app/App_Resources/iOS/checkbox_unchecked.png rename to tests/tns/app/App_Resources/iOS/checkbox_unchecked.png diff --git a/tests/app/App_Resources/iOS/icon-40.png b/tests/tns/app/App_Resources/iOS/icon-40.png similarity index 100% rename from tests/app/App_Resources/iOS/icon-40.png rename to tests/tns/app/App_Resources/iOS/icon-40.png diff --git a/tests/app/App_Resources/iOS/icon-40@2x.png b/tests/tns/app/App_Resources/iOS/icon-40@2x.png similarity index 100% rename from tests/app/App_Resources/iOS/icon-40@2x.png rename to tests/tns/app/App_Resources/iOS/icon-40@2x.png diff --git a/tests/app/App_Resources/iOS/icon-60.png b/tests/tns/app/App_Resources/iOS/icon-60.png similarity index 100% rename from tests/app/App_Resources/iOS/icon-60.png rename to tests/tns/app/App_Resources/iOS/icon-60.png diff --git a/tests/app/App_Resources/iOS/icon-60@2x.png b/tests/tns/app/App_Resources/iOS/icon-60@2x.png similarity index 100% rename from tests/app/App_Resources/iOS/icon-60@2x.png rename to tests/tns/app/App_Resources/iOS/icon-60@2x.png diff --git a/tests/app/App_Resources/iOS/icon-72.png b/tests/tns/app/App_Resources/iOS/icon-72.png similarity index 100% rename from tests/app/App_Resources/iOS/icon-72.png rename to tests/tns/app/App_Resources/iOS/icon-72.png diff --git a/tests/app/App_Resources/iOS/icon-72@2x.png b/tests/tns/app/App_Resources/iOS/icon-72@2x.png similarity index 100% rename from tests/app/App_Resources/iOS/icon-72@2x.png rename to tests/tns/app/App_Resources/iOS/icon-72@2x.png diff --git a/tests/app/App_Resources/iOS/icon-76.png b/tests/tns/app/App_Resources/iOS/icon-76.png similarity index 100% rename from tests/app/App_Resources/iOS/icon-76.png rename to tests/tns/app/App_Resources/iOS/icon-76.png diff --git a/tests/app/App_Resources/iOS/icon-76@2x.png b/tests/tns/app/App_Resources/iOS/icon-76@2x.png similarity index 100% rename from tests/app/App_Resources/iOS/icon-76@2x.png rename to tests/tns/app/App_Resources/iOS/icon-76@2x.png diff --git a/tests/app/App_Resources/iOS/icon.png b/tests/tns/app/App_Resources/iOS/icon.png similarity index 100% rename from tests/app/App_Resources/iOS/icon.png rename to tests/tns/app/App_Resources/iOS/icon.png diff --git a/tests/app/App_Resources/iOS/icon@2x.png b/tests/tns/app/App_Resources/iOS/icon@2x.png similarity index 100% rename from tests/app/App_Resources/iOS/icon@2x.png rename to tests/tns/app/App_Resources/iOS/icon@2x.png diff --git a/tests/app/LICENSE b/tests/tns/app/LICENSE similarity index 100% rename from tests/app/LICENSE rename to tests/tns/app/LICENSE diff --git a/tests/app/app.component.ts b/tests/tns/app/app.component.ts similarity index 100% rename from tests/app/app.component.ts rename to tests/tns/app/app.component.ts diff --git a/tests/app/app.css b/tests/tns/app/app.css similarity index 100% rename from tests/app/app.css rename to tests/tns/app/app.css diff --git a/tests/app/base.component.ts b/tests/tns/app/base.component.ts similarity index 100% rename from tests/app/base.component.ts rename to tests/tns/app/base.component.ts diff --git a/tests/app/first.component.ts b/tests/tns/app/first.component.ts similarity index 100% rename from tests/app/first.component.ts rename to tests/tns/app/first.component.ts diff --git a/tests/app/fonts/icomoon.ttf b/tests/tns/app/fonts/icomoon.ttf similarity index 100% rename from tests/app/fonts/icomoon.ttf rename to tests/tns/app/fonts/icomoon.ttf diff --git a/tests/app/global.d.ts b/tests/tns/app/global.d.ts similarity index 100% rename from tests/app/global.d.ts rename to tests/tns/app/global.d.ts diff --git a/tests/app/lazy-load-main.ts b/tests/tns/app/lazy-load-main.ts similarity index 100% rename from tests/app/lazy-load-main.ts rename to tests/tns/app/lazy-load-main.ts diff --git a/tests/app/lazy-loaded.module.ts b/tests/tns/app/lazy-loaded.module.ts similarity index 100% rename from tests/app/lazy-loaded.module.ts rename to tests/tns/app/lazy-loaded.module.ts diff --git a/tests/app/main.ts b/tests/tns/app/main.ts similarity index 100% rename from tests/app/main.ts rename to tests/tns/app/main.ts diff --git a/tests/app/multi-page-main.component.ts b/tests/tns/app/multi-page-main.component.ts similarity index 100% rename from tests/app/multi-page-main.component.ts rename to tests/tns/app/multi-page-main.component.ts diff --git a/tests/app/package.json b/tests/tns/app/package.json similarity index 100% rename from tests/app/package.json rename to tests/tns/app/package.json diff --git a/tests/app/second.component.ts b/tests/tns/app/second.component.ts similarity index 100% rename from tests/app/second.component.ts rename to tests/tns/app/second.component.ts diff --git a/tests/app/single-page-main.component.ts b/tests/tns/app/single-page-main.component.ts similarity index 100% rename from tests/app/single-page-main.component.ts rename to tests/tns/app/single-page-main.component.ts diff --git a/tests/app/snippets/gestures.component.html b/tests/tns/app/snippets/gestures.component.html similarity index 100% rename from tests/app/snippets/gestures.component.html rename to tests/tns/app/snippets/gestures.component.html diff --git a/tests/app/snippets/gestures.component.ts b/tests/tns/app/snippets/gestures.component.ts similarity index 100% rename from tests/app/snippets/gestures.component.ts rename to tests/tns/app/snippets/gestures.component.ts diff --git a/tests/app/snippets/icon-font.component.css b/tests/tns/app/snippets/icon-font.component.css similarity index 100% rename from tests/app/snippets/icon-font.component.css rename to tests/tns/app/snippets/icon-font.component.css diff --git a/tests/app/snippets/icon-font.component.html b/tests/tns/app/snippets/icon-font.component.html similarity index 100% rename from tests/app/snippets/icon-font.component.html rename to tests/tns/app/snippets/icon-font.component.html diff --git a/tests/app/snippets/icon-font.component.ts b/tests/tns/app/snippets/icon-font.component.ts similarity index 100% rename from tests/app/snippets/icon-font.component.ts rename to tests/tns/app/snippets/icon-font.component.ts diff --git a/tests/app/snippets/layouts.component.html b/tests/tns/app/snippets/layouts.component.html similarity index 100% rename from tests/app/snippets/layouts.component.html rename to tests/tns/app/snippets/layouts.component.html diff --git a/tests/app/snippets/layouts.component.ts b/tests/tns/app/snippets/layouts.component.ts similarity index 100% rename from tests/app/snippets/layouts.component.ts rename to tests/tns/app/snippets/layouts.component.ts diff --git a/tests/app/snippets/list-view/template-selector.component.html b/tests/tns/app/snippets/list-view/template-selector.component.html similarity index 100% rename from tests/app/snippets/list-view/template-selector.component.html rename to tests/tns/app/snippets/list-view/template-selector.component.html diff --git a/tests/app/snippets/list-view/template-selector.component.ts b/tests/tns/app/snippets/list-view/template-selector.component.ts similarity index 100% rename from tests/app/snippets/list-view/template-selector.component.ts rename to tests/tns/app/snippets/list-view/template-selector.component.ts diff --git a/tests/app/snippets/navigation/app.routes.ts b/tests/tns/app/snippets/navigation/app.routes.ts similarity index 100% rename from tests/app/snippets/navigation/app.routes.ts rename to tests/tns/app/snippets/navigation/app.routes.ts diff --git a/tests/app/snippets/navigation/config-snippets.ts b/tests/tns/app/snippets/navigation/config-snippets.ts similarity index 100% rename from tests/app/snippets/navigation/config-snippets.ts rename to tests/tns/app/snippets/navigation/config-snippets.ts diff --git a/tests/app/snippets/navigation/navigation-common.css b/tests/tns/app/snippets/navigation/navigation-common.css similarity index 100% rename from tests/app/snippets/navigation/navigation-common.css rename to tests/tns/app/snippets/navigation/navigation-common.css diff --git a/tests/app/snippets/navigation/navigation-common.ts b/tests/tns/app/snippets/navigation/navigation-common.ts similarity index 100% rename from tests/app/snippets/navigation/navigation-common.ts rename to tests/tns/app/snippets/navigation/navigation-common.ts diff --git a/tests/app/snippets/navigation/page-outlet.ts b/tests/tns/app/snippets/navigation/page-outlet.ts similarity index 100% rename from tests/app/snippets/navigation/page-outlet.ts rename to tests/tns/app/snippets/navigation/page-outlet.ts diff --git a/tests/app/snippets/navigation/route-params.ts b/tests/tns/app/snippets/navigation/route-params.ts similarity index 100% rename from tests/app/snippets/navigation/route-params.ts rename to tests/tns/app/snippets/navigation/route-params.ts diff --git a/tests/app/snippets/navigation/router-extensions.html b/tests/tns/app/snippets/navigation/router-extensions.html similarity index 100% rename from tests/app/snippets/navigation/router-extensions.html rename to tests/tns/app/snippets/navigation/router-extensions.html diff --git a/tests/app/snippets/navigation/router-extensions.ts b/tests/tns/app/snippets/navigation/router-extensions.ts similarity index 100% rename from tests/app/snippets/navigation/router-extensions.ts rename to tests/tns/app/snippets/navigation/router-extensions.ts diff --git a/tests/app/snippets/navigation/router-outlet.ts b/tests/tns/app/snippets/navigation/router-outlet.ts similarity index 100% rename from tests/app/snippets/navigation/router-outlet.ts rename to tests/tns/app/snippets/navigation/router-outlet.ts diff --git a/tests/app/tests/detached-loader-tests.ts b/tests/tns/app/tests/detached-loader-tests.ts similarity index 100% rename from tests/app/tests/detached-loader-tests.ts rename to tests/tns/app/tests/detached-loader-tests.ts diff --git a/tests/app/tests/http.ts b/tests/tns/app/tests/http.ts similarity index 100% rename from tests/app/tests/http.ts rename to tests/tns/app/tests/http.ts diff --git a/tests/app/tests/list-view-tests.ts b/tests/tns/app/tests/list-view-tests.ts similarity index 100% rename from tests/app/tests/list-view-tests.ts rename to tests/tns/app/tests/list-view-tests.ts diff --git a/tests/app/tests/mocks/ns-file-system.mock.ts b/tests/tns/app/tests/mocks/ns-file-system.mock.ts similarity index 100% rename from tests/app/tests/mocks/ns-file-system.mock.ts rename to tests/tns/app/tests/mocks/ns-file-system.mock.ts diff --git a/tests/app/tests/modal-dialog.ts b/tests/tns/app/tests/modal-dialog.ts similarity index 100% rename from tests/app/tests/modal-dialog.ts rename to tests/tns/app/tests/modal-dialog.ts diff --git a/tests/app/tests/ns-location-strategy.ts b/tests/tns/app/tests/ns-location-strategy.ts similarity index 100% rename from tests/app/tests/ns-location-strategy.ts rename to tests/tns/app/tests/ns-location-strategy.ts diff --git a/tests/app/tests/platform-filter-components.ts b/tests/tns/app/tests/platform-filter-components.ts similarity index 97% rename from tests/app/tests/platform-filter-components.ts rename to tests/tns/app/tests/platform-filter-components.ts index 5665e1364..9cdbf7b60 100644 --- a/tests/app/tests/platform-filter-components.ts +++ b/tests/tns/app/tests/platform-filter-components.ts @@ -1,122 +1,122 @@ -// make sure you import mocha-config before @angular/core -import { assert } from "./test-config"; -import { Component, ElementRef } from "@angular/core"; -import { dumpView, createDevice } from "./test-utils"; -import { TestApp } from "./test-app"; -import { DEVICE } from "nativescript-angular/platform-providers"; -import { platformNames } from "platform"; - -@Component({ - template: ` - - - ` -}) -export class IosSpecificComponent { - constructor(public elementRef: ElementRef) { } -} - -@Component({ - template: ` - - - ` -}) -export class AndroidSpecificComponent { - constructor(public elementRef: ElementRef) { } -} - -@Component({ - template: ` - - - ` -}) -export class PlatformSpecificAttributeComponent { - constructor(public elementRef: ElementRef) { } -} - -describe("Platform filter directives", () => { - describe("on IOS device", () => { - let testApp: TestApp = null; - - before(() => { - return TestApp.create([{ provide: DEVICE, useValue: createDevice(platformNames.ios) }], [ - PlatformSpecificAttributeComponent, - AndroidSpecificComponent, - IosSpecificComponent - ]).then((app) => { - testApp = app; - }); - }); - - after(() => { - testApp.dispose(); - }); - - it("does render ios specific content", () => { - return testApp.loadComponent(IosSpecificComponent).then((componentRef) => { - const componentRoot = componentRef.instance.elementRef.nativeElement; - assert.isTrue(dumpView(componentRoot, true).indexOf("(Label[text=IOS])") >= 0); - }); - }); - - it("does not render android specific content", () => { - return testApp.loadComponent(AndroidSpecificComponent).then((componentRef) => { - const componentRoot = componentRef.instance.elementRef.nativeElement; - assert.isTrue(dumpView(componentRoot, true).indexOf("Label") < 0); - }); - }); - - - it("applies iOS specific attribute", () => { - return testApp.loadComponent(PlatformSpecificAttributeComponent).then((componentRef) => { - const componentRoot = componentRef.instance.elementRef.nativeElement; - assert.equal( - "(ProxyViewContainer (StackLayout (Label[text=IOS])))", - dumpView(componentRoot, true)); - }); - }); - }); - - describe("on Android device", () => { - let testApp: TestApp = null; - - before(() => { - return TestApp.create([{ provide: DEVICE, useValue: createDevice(platformNames.android) }], [ - AndroidSpecificComponent, - IosSpecificComponent, - PlatformSpecificAttributeComponent - ]).then((app) => { - testApp = app; - }); - }); - - after(() => { - testApp.dispose(); - }); - - it("does render android specific content", () => { - return testApp.loadComponent(AndroidSpecificComponent).then((componentRef) => { - const componentRoot = componentRef.instance.elementRef.nativeElement; - assert.isTrue(dumpView(componentRoot, true).indexOf("(Label[text=ANDROID])") >= 0); - }); - }); - - it("does not render ios specific content", () => { - return testApp.loadComponent(IosSpecificComponent).then((componentRef) => { - const componentRoot = componentRef.instance.elementRef.nativeElement; - assert.isTrue(dumpView(componentRoot, true).indexOf("Label") < 0); - }); - }); - - it("applies Android specific attribute", () => { - return testApp.loadComponent(PlatformSpecificAttributeComponent).then((componentRef) => { - const componentRoot = componentRef.instance.elementRef.nativeElement; - assert.equal( - "(ProxyViewContainer (StackLayout (Label[text=ANDROID])))", - dumpView(componentRoot, true)); - }); - }); - }); -}); +// make sure you import mocha-config before @angular/core +import { assert } from "./test-config"; +import { Component, ElementRef } from "@angular/core"; +import { dumpView, createDevice } from "./test-utils"; +import { TestApp } from "./test-app"; +import { DEVICE } from "nativescript-angular/platform-providers"; +import { platformNames } from "platform"; + +@Component({ + template: ` + + + ` +}) +export class IosSpecificComponent { + constructor(public elementRef: ElementRef) { } +} + +@Component({ + template: ` + + + ` +}) +export class AndroidSpecificComponent { + constructor(public elementRef: ElementRef) { } +} + +@Component({ + template: ` + + + ` +}) +export class PlatformSpecificAttributeComponent { + constructor(public elementRef: ElementRef) { } +} + +describe("Platform filter directives", () => { + describe("on IOS device", () => { + let testApp: TestApp = null; + + before(() => { + return TestApp.create([{ provide: DEVICE, useValue: createDevice(platformNames.ios) }], [ + PlatformSpecificAttributeComponent, + AndroidSpecificComponent, + IosSpecificComponent + ]).then((app) => { + testApp = app; + }); + }); + + after(() => { + testApp.dispose(); + }); + + it("does render ios specific content", () => { + return testApp.loadComponent(IosSpecificComponent).then((componentRef) => { + const componentRoot = componentRef.instance.elementRef.nativeElement; + assert.isTrue(dumpView(componentRoot, true).indexOf("(Label[text=IOS])") >= 0); + }); + }); + + it("does not render android specific content", () => { + return testApp.loadComponent(AndroidSpecificComponent).then((componentRef) => { + const componentRoot = componentRef.instance.elementRef.nativeElement; + assert.isTrue(dumpView(componentRoot, true).indexOf("Label") < 0); + }); + }); + + + it("applies iOS specific attribute", () => { + return testApp.loadComponent(PlatformSpecificAttributeComponent).then((componentRef) => { + const componentRoot = componentRef.instance.elementRef.nativeElement; + assert.equal( + "(ProxyViewContainer (StackLayout (Label[text=IOS])))", + dumpView(componentRoot, true)); + }); + }); + }); + + describe("on Android device", () => { + let testApp: TestApp = null; + + before(() => { + return TestApp.create([{ provide: DEVICE, useValue: createDevice(platformNames.android) }], [ + AndroidSpecificComponent, + IosSpecificComponent, + PlatformSpecificAttributeComponent + ]).then((app) => { + testApp = app; + }); + }); + + after(() => { + testApp.dispose(); + }); + + it("does render android specific content", () => { + return testApp.loadComponent(AndroidSpecificComponent).then((componentRef) => { + const componentRoot = componentRef.instance.elementRef.nativeElement; + assert.isTrue(dumpView(componentRoot, true).indexOf("(Label[text=ANDROID])") >= 0); + }); + }); + + it("does not render ios specific content", () => { + return testApp.loadComponent(IosSpecificComponent).then((componentRef) => { + const componentRoot = componentRef.instance.elementRef.nativeElement; + assert.isTrue(dumpView(componentRoot, true).indexOf("Label") < 0); + }); + }); + + it("applies Android specific attribute", () => { + return testApp.loadComponent(PlatformSpecificAttributeComponent).then((componentRef) => { + const componentRoot = componentRef.instance.elementRef.nativeElement; + assert.equal( + "(ProxyViewContainer (StackLayout (Label[text=ANDROID])))", + dumpView(componentRoot, true)); + }); + }); + }); +}); diff --git a/tests/app/tests/property-sets.ts b/tests/tns/app/tests/property-sets.ts similarity index 100% rename from tests/app/tests/property-sets.ts rename to tests/tns/app/tests/property-sets.ts diff --git a/tests/app/tests/renderer-tests.ts b/tests/tns/app/tests/renderer-tests.ts similarity index 100% rename from tests/app/tests/renderer-tests.ts rename to tests/tns/app/tests/renderer-tests.ts diff --git a/tests/app/tests/snippets.ts b/tests/tns/app/tests/snippets.ts similarity index 100% rename from tests/app/tests/snippets.ts rename to tests/tns/app/tests/snippets.ts diff --git a/tests/app/tests/style-properties.ts b/tests/tns/app/tests/style-properties.ts similarity index 100% rename from tests/app/tests/style-properties.ts rename to tests/tns/app/tests/style-properties.ts diff --git a/tests/app/tests/test-app.ts b/tests/tns/app/tests/test-app.ts similarity index 100% rename from tests/app/tests/test-app.ts rename to tests/tns/app/tests/test-app.ts diff --git a/tests/app/tests/test-config.ts b/tests/tns/app/tests/test-config.ts similarity index 100% rename from tests/app/tests/test-config.ts rename to tests/tns/app/tests/test-config.ts diff --git a/tests/app/tests/test-utils.ts b/tests/tns/app/tests/test-utils.ts similarity index 96% rename from tests/app/tests/test-utils.ts rename to tests/tns/app/tests/test-utils.ts index 30a4427a1..b664ef2c8 100644 --- a/tests/app/tests/test-utils.ts +++ b/tests/tns/app/tests/test-utils.ts @@ -1,45 +1,45 @@ -import { View } from "ui/core/view"; -import { TextBase } from "ui/text-base"; -import { Device } from "platform"; - -function getChildren(view: View): Array { - let children: Array = []; - (view).eachChildView((child) => { - children.push(child); - return true; - }); - return children; -} - -export function dumpView(view: View, verbose: boolean = false): string { - let nodeName = (view).nodeName || view; - let output = ["(", nodeName]; - if (verbose) { - if (view instanceof TextBase) { - output.push("[text=", view.text, "]"); - } - } - - let children = getChildren(view).map((c) => dumpView(c, verbose)).join(", "); - if (children) { - output.push(" ", children); - } - - output.push(")"); - return output.join(""); -} - -export function createDevice(os: string): Device { - return { - os: os, - osVersion: "0", - deviceType: "Phone", - language: "en", - uuid: "0000", - sdkVersion: "0", - region: "US", - manufacturer: "tester", - model: "test device" - }; -} - +import { View } from "ui/core/view"; +import { TextBase } from "ui/text-base"; +import { Device } from "platform"; + +function getChildren(view: View): Array { + let children: Array = []; + (view).eachChildView((child) => { + children.push(child); + return true; + }); + return children; +} + +export function dumpView(view: View, verbose: boolean = false): string { + let nodeName = (view).nodeName || view; + let output = ["(", nodeName]; + if (verbose) { + if (view instanceof TextBase) { + output.push("[text=", view.text, "]"); + } + } + + let children = getChildren(view).map((c) => dumpView(c, verbose)).join(", "); + if (children) { + output.push(" ", children); + } + + output.push(")"); + return output.join(""); +} + +export function createDevice(os: string): Device { + return { + os: os, + osVersion: "0", + deviceType: "Phone", + language: "en", + uuid: "0000", + sdkVersion: "0", + region: "US", + manufacturer: "tester", + model: "test device" + }; +} + diff --git a/tests/app/tests/third-party-view.ts b/tests/tns/app/tests/third-party-view.ts similarity index 100% rename from tests/app/tests/third-party-view.ts rename to tests/tns/app/tests/third-party-view.ts diff --git a/tests/app/tests/third-party.ts b/tests/tns/app/tests/third-party.ts similarity index 100% rename from tests/app/tests/third-party.ts rename to tests/tns/app/tests/third-party.ts diff --git a/tests/app/tests/value-accessor-tests.ts b/tests/tns/app/tests/value-accessor-tests.ts similarity index 100% rename from tests/app/tests/value-accessor-tests.ts rename to tests/tns/app/tests/value-accessor-tests.ts diff --git a/tests/app/tests/xhr-paths.ts b/tests/tns/app/tests/xhr-paths.ts similarity index 100% rename from tests/app/tests/xhr-paths.ts rename to tests/tns/app/tests/xhr-paths.ts diff --git a/tests/e2e-tests/lazy-load-routing.js b/tests/tns/e2e-tests/lazy-load-routing.js similarity index 100% rename from tests/e2e-tests/lazy-load-routing.js rename to tests/tns/e2e-tests/lazy-load-routing.js diff --git a/tests/e2e-tests/multi-page-routing.js b/tests/tns/e2e-tests/multi-page-routing.js similarity index 100% rename from tests/e2e-tests/multi-page-routing.js rename to tests/tns/e2e-tests/multi-page-routing.js diff --git a/tests/e2e-tests/single-page-routing.js b/tests/tns/e2e-tests/single-page-routing.js similarity index 100% rename from tests/e2e-tests/single-page-routing.js rename to tests/tns/e2e-tests/single-page-routing.js diff --git a/tests/hooks/after-prepare/nativescript-unit-test-runner.js b/tests/tns/hooks/after-prepare/nativescript-unit-test-runner.js similarity index 100% rename from tests/hooks/after-prepare/nativescript-unit-test-runner.js rename to tests/tns/hooks/after-prepare/nativescript-unit-test-runner.js diff --git a/tests/hooks/before-livesync/nativescript-angular-sync.js b/tests/tns/hooks/before-livesync/nativescript-angular-sync.js similarity index 100% rename from tests/hooks/before-livesync/nativescript-angular-sync.js rename to tests/tns/hooks/before-livesync/nativescript-angular-sync.js diff --git a/tests/hooks/before-prepare/nativescript-dev-typescript.js b/tests/tns/hooks/before-prepare/nativescript-dev-typescript.js similarity index 100% rename from tests/hooks/before-prepare/nativescript-dev-typescript.js rename to tests/tns/hooks/before-prepare/nativescript-dev-typescript.js diff --git a/tests/hooks/before-watch/nativescript-dev-typescript.js b/tests/tns/hooks/before-watch/nativescript-dev-typescript.js similarity index 100% rename from tests/hooks/before-watch/nativescript-dev-typescript.js rename to tests/tns/hooks/before-watch/nativescript-dev-typescript.js diff --git a/tests/karma.conf.js b/tests/tns/karma.conf.js similarity index 100% rename from tests/karma.conf.js rename to tests/tns/karma.conf.js diff --git a/tests/package.json b/tests/tns/package.json similarity index 92% rename from tests/package.json rename to tests/tns/package.json index 7b579e011..7a87652a9 100644 --- a/tests/package.json +++ b/tests/tns/package.json @@ -65,6 +65,9 @@ "wd": "0.4.0" }, "scripts": { + "test": "npm run test-android", + "test-android": "tns test android --emulator --justlaunch", + "test-ios": "tns test ios --emulator --justlaunch", "updateTests": "grunt updateTests", "appium-android": "tns build android && npm run run-appium-android", "run-appium-android": "nativescript-dev-appium android", diff --git a/tests/references.d.ts b/tests/tns/references.d.ts similarity index 100% rename from tests/references.d.ts rename to tests/tns/references.d.ts diff --git a/tests/tsconfig.json b/tests/tns/tsconfig.json similarity index 100% rename from tests/tsconfig.json rename to tests/tns/tsconfig.json diff --git a/tests/tslint.json b/tests/tns/tslint.json similarity index 100% rename from tests/tslint.json rename to tests/tns/tslint.json diff --git a/tests/typings/chai.d.ts b/tests/typings/chai.d.ts deleted file mode 100644 index 113158d83..000000000 --- a/tests/typings/chai.d.ts +++ /dev/null @@ -1,283 +0,0 @@ -// Type definitions for chai 1.7.2 -// Project: http://chaijs.com/ -// Definitions by: Jed Hunsaker , Bart van der Schoor -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -declare module chai { - export class AssertionError { - constructor(message: string, _props?: any, ssf?: Function); - name: string; - message: string; - showDiff: boolean; - stack: string; - } - - function expect(target: any, message?: string): Expect; - - export var assert: Assert; - export var config: Config; - - export interface Config { - includeStack: boolean; - } - - // Provides a way to extend the internals of Chai - function use(fn: (chai: any, utils: any) => void): any; - - interface ExpectStatic { - (target: any): Expect; - } - - interface Assertions { - attr(name: string, value?: string): any; - css(name: string, value?: string): any; - data(name: string, value?: string): any; - class(className: string): any; - id(id: string): any; - html(html: string): any; - text(text: string): any; - value(value: string): any; - visible: any; - hidden: any; - selected: any; - checked: any; - disabled: any; - empty: any; - exist: any; - } - - interface Expect extends LanguageChains, NumericComparison, TypeComparison, Assertions { - not: Expect; - deep: Deep; - a: TypeComparison; - an: TypeComparison; - include: Include; - contain: Include; - ok: Expect; - true: Expect; - false: Expect; - null: Expect; - undefined: Expect; - exist: Expect; - empty: Expect; - arguments: Expect; - Arguments: Expect; - equal: Equal; - equals: Equal; - eq: Equal; - eql: Equal; - eqls: Equal; - property: Property; - ownProperty: OwnProperty; - haveOwnProperty: OwnProperty; - length: Length; - lengthOf: Length; - match(RegularExpression: RegExp, message?: string): Expect; - string(string: string, message?: string): Expect; - keys: Keys; - key(string: string): Expect; - throw: Throw; - throws: Throw; - Throw: Throw; - respondTo(method: string, message?: string): Expect; - itself: Expect; - satisfy(matcher: Function, message?: string): Expect; - closeTo(expected: number, delta: number, message?: string): Expect; - members: Members; - } - - interface LanguageChains { - to: Expect; - be: Expect; - been: Expect; - is: Expect; - that: Expect; - and: Expect; - have: Expect; - with: Expect; - at: Expect; - of: Expect; - same: Expect; - } - - interface NumericComparison { - above: NumberComparer; - gt: NumberComparer; - greaterThan: NumberComparer; - least: NumberComparer; - gte: NumberComparer; - below: NumberComparer; - lt: NumberComparer; - lessThan: NumberComparer; - most: NumberComparer; - lte: NumberComparer; - within(start: number, finish: number, message?: string): Expect; - } - - interface NumberComparer { - (value: number, message?: string): Expect; - } - - interface TypeComparison { - (type: string, message?: string): Expect; - instanceof: InstanceOf; - instanceOf: InstanceOf; - } - - interface InstanceOf { - (constructor: Object, message?: string): Expect; - } - - interface Deep { - equal: Equal; - property: Property; - } - - interface Equal { - (value: any, message?: string): Expect; - } - - interface Property { - (name: string, value?: any, message?: string): Expect; - } - - interface OwnProperty { - (name: string, message?: string): Expect; - } - - interface Length extends LanguageChains, NumericComparison { - (length: number, message?: string): Expect; - } - - interface Include { - (value: Object, message?: string): Expect; - (value: string, message?: string): Expect; - (value: number, message?: string): Expect; - keys: Keys; - members: Members; - } - - interface Keys { - (...keys: string[]): Expect; - (keys: any[]): Expect; - } - - interface Members { - (set: any[], message?: string): Expect; - } - - interface Throw { - (): Expect; - (expected: string, message?: string): Expect; - (expected: RegExp, message?: string): Expect; - (constructor: Error, expected?: string, message?: string): Expect; - (constructor: Error, expected?: RegExp, message?: string): Expect; - (constructor: Function, expected?: string, message?: string): Expect; - (constructor: Function, expected?: RegExp, message?: string): Expect; - } - - export interface Assert { - (express: any, msg?: string):void; - - fail(actual?: any, expected?: any, msg?: string, operator?: string):void; - - ok(val: any, msg?: string):void; - notOk(val: any, msg?: string):void; - - equal(act: any, exp: any, msg?: string):void; - notEqual(act: any, exp: any, msg?: string):void; - - strictEqual(act: any, exp: any, msg?: string):void; - notStrictEqual(act: any, exp: any, msg?: string):void; - - deepEqual(act: any, exp: any, msg?: string):void; - notDeepEqual(act: any, exp: any, msg?: string):void; - - isTrue(val: any, msg?: string):void; - isFalse(val: any, msg?: string):void; - - isNull(val: any, msg?: string):void; - isNotNull(val: any, msg?: string):void; - - isUndefined(val: any, msg?: string):void; - isDefined(val: any, msg?: string):void; - - isFunction(val: any, msg?: string):void; - isNotFunction(val: any, msg?: string):void; - - isObject(val: any, msg?: string):void; - isNotObject(val: any, msg?: string):void; - - isArray(val: any, msg?: string):void; - isNotArray(val: any, msg?: string):void; - - isString(val: any, msg?: string):void; - isNotString(val: any, msg?: string):void; - - isNumber(val: any, msg?: string):void; - isNotNumber(val: any, msg?: string):void; - - isBoolean(val: any, msg?: string):void; - isNotBoolean(val: any, msg?: string):void; - - typeOf(val: any, type: string, msg?: string):void; - notTypeOf(val: any, type: string, msg?: string):void; - - instanceOf(val: any, type: Function, msg?: string):void; - notInstanceOf(val: any, type: Function, msg?: string):void; - - include(exp: string, inc: any, msg?: string):void; - include(exp: any[], inc: any, msg?: string):void; - - notInclude(exp: string, inc: any, msg?: string):void; - notInclude(exp: any[], inc: any, msg?: string):void; - - match(exp: any, re: RegExp, msg?: string):void; - notMatch(exp: any, re: RegExp, msg?: string):void; - - property(obj: Object, prop: string, msg?: string):void; - notProperty(obj: Object, prop: string, msg?: string):void; - deepProperty(obj: Object, prop: string, msg?: string):void; - notDeepProperty(obj: Object, prop: string, msg?: string):void; - - propertyVal(obj: Object, prop: string, val: any, msg?: string):void; - propertyNotVal(obj: Object, prop: string, val: any, msg?: string):void; - - deepPropertyVal(obj: Object, prop: string, val: any, msg?: string):void; - deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string):void; - - lengthOf(exp: any, len: number, msg?: string):void; - //alias frenzy - throw(fn: Function, msg?: string):void; - throw(fn: Function, regExp: RegExp):void; - throw(fn: Function, errType: Function, msg?: string):void; - throw(fn: Function, errType: Function, regExp: RegExp):void; - - throws(fn: Function, msg?: string):void; - throws(fn: Function, regExp: RegExp):void; - throws(fn: Function, errType: Function, msg?: string):void; - throws(fn: Function, errType: Function, regExp: RegExp):void; - - Throw(fn: Function, msg?: string):void; - Throw(fn: Function, regExp: RegExp):void; - Throw(fn: Function, errType: Function, msg?: string):void; - Throw(fn: Function, errType: Function, regExp: RegExp):void; - - doesNotThrow(fn: Function, msg?: string):void; - doesNotThrow(fn: Function, regExp: RegExp):void; - doesNotThrow(fn: Function, errType: Function, msg?: string):void; - doesNotThrow(fn: Function, errType: Function, regExp: RegExp):void; - - operator(val: any, operator: string, val2: any, msg?: string):void; - closeTo(act: number, exp: number, delta: number, msg?: string):void; - - sameMembers(set1: any[], set2: any[], msg?: string):void; - includeMembers(set1: any[], set2: any[], msg?: string):void; - - ifError(val: any, msg?: string):void; - } -} - -declare module "chai" { -export = chai; -} diff --git a/tests/typings/mocha.d.ts b/tests/typings/mocha.d.ts deleted file mode 100644 index 8d49749b7..000000000 --- a/tests/typings/mocha.d.ts +++ /dev/null @@ -1,86 +0,0 @@ -// Type definitions for mocha 1.9.0 -// Project: http://visionmedia.github.io/mocha/ -// Definitions by: Kazi Manzur Rashid -// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped - -interface Mocha { - // Setup mocha with the given setting options. - setup(options: MochaSetupOptions): Mocha; - - //Run tests and invoke `fn()` when complete. - run(callback?: () => void): void; - - // Set reporter as function - reporter(reporter: () => void): Mocha; - - // Set reporter, defaults to "dot" - reporter(reporter: string): Mocha; - - // Enable growl support. - growl(): Mocha -} - -interface MochaSetupOptions { - //milliseconds to wait before considering a test slow - slow?: number; - - // timeout in milliseconds - timeout?: number; - - // ui name "bdd", "tdd", "exports" etc - ui?: string; - - //array of accepted globals - globals?: any[]; - - // reporter instance (function or string), defaults to `mocha.reporters.Dot` - reporter?: any; - - // bail on the first test failure - bail?: Boolean; - - // ignore global leaks - ignoreLeaks?: Boolean; - - // grep string or regexp to filter tests with - grep?: any; -} - -declare module mocha { - interface Done { - (error?: Error): void; - } -} - -declare var describe : { - (description: string, spec: () => void): void; - only(description: string, spec: () => void): void; - skip(description: string, spec: () => void): void; - timeout(ms: number): void; -} - -declare var it: { - (expectation: string, assertion?: () => void): void; - (expectation: string, assertion?: (done: mocha.Done) => void): void; - only(expectation: string, assertion?: () => void): void; - only(expectation: string, assertion?: (done: mocha.Done) => void): void; - skip(expectation: string, assertion?: () => void): void; - skip(expectation: string, assertion?: (done: mocha.Done) => void): void; - timeout(ms: number): void; -}; - -declare function before(action: () => void): void; - -declare function before(action: (done: mocha.Done) => void): void; - -declare function after(action: () => void): void; - -declare function after(action: (done: mocha.Done) => void): void; - -declare function beforeEach(action: () => void): void; - -declare function beforeEach(action: (done: mocha.Done) => void): void; - -declare function afterEach(action: () => void): void; - -declare function afterEach(action: (done: mocha.Done) => void): void;