Skip to content

Commit d180a80

Browse files
committed
Use npm package for tests project
1 parent 1c677a0 commit d180a80

16 files changed

Lines changed: 62 additions & 46 deletions

‎.gitignore‎

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

1112
tests/app/**/*.js
12-
tests/app/global.d.ts
1313
tests/test-output.txt
14-
tests/app/nativescript-angular
15-
tests/app/global.d.ts
1614
tests/platforms
1715
tests/lib
1816
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
@@ -15,7 +15,7 @@ import 'globals';
1515
import 'reflect-metadata';
1616
import './polyfills/array';
1717
import {isPresent, Type} from 'angular2/src/facade/lang';
18-
import {platform, ComponentRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/core';
18+
import {platform, ComponentRef, PlatformRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/core';
1919
import {bind, provide, Provider} from 'angular2/src/core/di';
2020
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
2121

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

48-
let _platform = null;
48+
let _platform: PlatformRef = null;
4949

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

7171
defaultPageProvider,
7272
defaultDeviceProvider,
7373
NativeScriptRootRenderer,
74-
provide(RootRenderer, {useClass: NativeScriptRootRenderer}),
74+
provide(RootRenderer, { useClass: NativeScriptRootRenderer }),
7575
NativeScriptRenderer,
76-
provide(Renderer, {useClass: NativeScriptRenderer}),
76+
provide(Renderer, { useClass: NativeScriptRenderer }),
7777
COMPILER_PROVIDERS,
78-
provide(XHR, {useClass: FileSystemXHR}),
78+
provide(XHR, { useClass: FileSystemXHR }),
7979
]
8080

8181
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)