Skip to content

Commit 506067e

Browse files
committed
Use npm package for tests project
1 parent 65d17c8 commit 506067e

16 files changed

+115
-99
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ src/nativescript-angular/**/*.js
66
.tscache
77
.nvm
88
.vscode
9+
nativescript-angular*.tgz
910

1011
tests/app/**/*.js
11-
tests/app/global.d.ts
1212
tests/test-output.txt
13-
tests/app/nativescript-angular
14-
tests/app/global.d.ts
1513
tests/platforms
1614
tests/lib
1715
tests/node_modules

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ before_script:
2929
- android-wait-for-emulator
3030

3131
script:
32+
- npm install
3233
- cd ./tests
3334
- npm install
3435
- tns platform add android

gruntfile.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = function(grunt) {
1010

1111
var outDir = "bin/dist/modules";
1212
var moduleOutDir = path.join(outDir, "nativescript-angular");
13+
var packageName = "nativescript-angular-" + require("./package.json").version + ".tgz";
1314

1415
grunt.initConfig({
1516
ts: {
@@ -65,14 +66,27 @@ module.exports = function(grunt) {
6566
package: {
6667
src: 'nativescript-angular*.tgz'
6768
},
68-
packageDefinitions: {
69-
src: moduleOutDir + '/**/*.d.ts'
70-
}
7169
},
7270
shell: {
7371
package: {
7472
command: "npm pack \"" + moduleOutDir + "\""
7573
},
74+
updateTests: {
75+
command: "npm install ../" + packageName,
76+
options: {
77+
execOptions: {
78+
cwd: "./tests"
79+
}
80+
}
81+
},
82+
updateSamples: {
83+
command: "npm install ../" + packageName,
84+
options: {
85+
execOptions: {
86+
cwd: "./ng-sample"
87+
}
88+
}
89+
}
7690
},
7791
});
7892

@@ -84,7 +98,6 @@ module.exports = function(grunt) {
8498
]);
8599

86100
grunt.registerTask("package", [
87-
"clean:packageDefinitions",
88101
"copy:handCodedDefinitions",
89102
"copy:npmReadme",
90103
"shell:package",
@@ -101,5 +114,9 @@ module.exports = function(grunt) {
101114
"package"
102115
]);
103116

117+
grunt.registerTask("updateTests", ["all", "shell:updateTests"]);
118+
119+
grunt.registerTask("updateSamples", ["all", "shell:updateSamples"]);
120+
104121
grunt.registerTask("default", ["all"]);
105122
};
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Type, ApplicationRef, Provider } from 'angular2/core';
1+
import { Type, ComponentRef, Provider } from 'angular2/core';
22

33
export interface AppOptions {
44
cssFile?: string;
55
startPageActionBarHidden?: boolean;
66
}
77

8-
export type BindingArray = Array<Type | Provider | Array<any>>;
9-
export function bootstrap(appComponentType: any, componentInjectableBindings?: BindingArray): Promise<ApplicationRef>;
10-
export function nativeScriptBootstrap(appComponentType: any, customProviders?: BindingArray, appOptions?: any): void;
8+
export type ProviderArray = Array<Type | Provider | Array<any>>;
9+
export function bootstrap(appComponentType: any, componentInjectableBindings?: ProviderArray): Promise<ComponentRef>;
10+
export function nativeScriptBootstrap(appComponentType: any, customProviders?: ProviderArray, appOptions?: any): void;

src/nativescript-angular/application.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ delete global.process;
1414
import 'reflect-metadata';
1515
import './polyfills/array';
1616
import {isPresent, Type} from 'angular2/src/facade/lang';
17-
import {platform, ComponentRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/core';
17+
import {platform, ComponentRef, PlatformRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/core';
1818
import {bind, provide, Provider} from 'angular2/src/core/di';
1919
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
2020

@@ -44,7 +44,7 @@ import {defaultPageProvider, defaultDeviceProvider} from "./platform-providers";
4444
import * as nativescriptIntl from "nativescript-intl";
4545
global.Intl = nativescriptIntl;
4646

47-
let _platform = null;
47+
let _platform: PlatformRef = null;
4848

4949
export interface AppOptions {
5050
cssFile?: string;
@@ -62,19 +62,19 @@ export function bootstrap(appComponentType: any,
6262
let defaultAppProviders: ProviderArray = [
6363
APPLICATION_COMMON_PROVIDERS,
6464
FORM_PROVIDERS,
65-
provide(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
66-
provide(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
67-
provide(PLATFORM_DIRECTIVES, {useValue: NS_DIRECTIVES, multi: true}),
68-
provide(ExceptionHandler, {useFactory: () => new ExceptionHandler(DOM, true), deps: []}),
65+
provide(PLATFORM_PIPES, { useValue: COMMON_PIPES, multi: true }),
66+
provide(PLATFORM_DIRECTIVES, { useValue: COMMON_DIRECTIVES, multi: true }),
67+
provide(PLATFORM_DIRECTIVES, { useValue: NS_DIRECTIVES, multi: true }),
68+
provide(ExceptionHandler, { useFactory: () => new ExceptionHandler(DOM, true), deps: [] }),
6969

7070
defaultPageProvider,
7171
defaultDeviceProvider,
7272
NativeScriptRootRenderer,
73-
provide(RootRenderer, {useClass: NativeScriptRootRenderer}),
73+
provide(RootRenderer, { useClass: NativeScriptRootRenderer }),
7474
NativeScriptRenderer,
75-
provide(Renderer, {useClass: NativeScriptRenderer}),
75+
provide(Renderer, { useClass: NativeScriptRenderer }),
7676
COMPILER_PROVIDERS,
77-
provide(XHR, {useClass: FileSystemXHR}),
77+
provide(XHR, { useClass: FileSystemXHR }),
7878
]
7979

8080
var appProviders = [defaultAppProviders];

tests/app/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="../node_modules/tns-core-modules/tns-core-modules.d.ts" />

tests/app/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// this import should be first in order to load some required settings (like globals and reflect-metadata)
2-
import {nativeScriptBootstrap} from "./nativescript-angular/application";
2+
import {nativeScriptBootstrap} from "nativescript-angular/application";
33
import {AppComponent} from "./app.component";
44

55
nativeScriptBootstrap(AppComponent);

tests/app/tests/bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//make sure you import mocha-config before angular2/core
22
import {assert} from "./test-config";
3-
import {bootstrap} from "../nativescript-angular/application";
3+
import {bootstrap} from "nativescript-angular/application";
44
import {Component} from "angular2/core";
55

66
@Component({

tests/app/tests/modal-dialog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Component, ComponentRef} from "angular2/core";
44
import {TestApp} from "./test-app";
55
import {Page} from "ui/page";
66
import {topmost} from "ui/frame";
7-
import {ModalDialogHost, ModalDialogOptions, ModalDialogParams, ModalDialogService} from "../nativescript-angular/directives/dialogs";
7+
import {ModalDialogHost, ModalDialogOptions, ModalDialogParams, ModalDialogService} from "nativescript-angular/directives/dialogs";
88

99
@Component({
1010
selector: "modal-comp",

tests/app/tests/platform-filter-components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Component, ElementRef, provide} from "angular2/core";
44
import {ProxyViewContainer} from "ui/proxy-view-container";
55
import {dumpView, createDevice} from "./test-utils";
66
import {TestApp} from "./test-app";
7-
import {DEVICE} from "../nativescript-angular/platform-providers";
7+
import {DEVICE} from "nativescript-angular/platform-providers";
88
import {platformNames} from "platform";
99

1010
@Component({

0 commit comments

Comments
 (0)