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

Diff for: .gitignore

+1-3
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

Diff for: .travis.yml

+1
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

Diff for: gruntfile.js

+21-4
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
};

Diff for: src/nativescript-angular/application.d.ts

+4-4
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;

Diff for: src/nativescript-angular/application.ts

+9-9
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];

Diff for: tests/app/global.d.ts

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

Diff for: tests/app/main.ts

+1-1
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);

Diff for: tests/app/tests/bootstrap.ts

+1-1
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({

Diff for: tests/app/tests/modal-dialog.ts

+1-1
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",

Diff for: tests/app/tests/platform-filter-components.ts

+1-1
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({

Diff for: tests/app/tests/property-sets.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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
import {View} from "ui/core/view";
6-
import {ViewUtil} from "../nativescript-angular/view-util";
7-
import {NgView, ViewExtensions, ViewClassMeta} from "../nativescript-angular/element-registry";
6+
import {ViewUtil} from "nativescript-angular/view-util";
7+
import {NgView, ViewExtensions, ViewClassMeta} from "nativescript-angular/element-registry";
88
import {Red} from "color/known-colors";
99
import {device, Device, platformNames} from "platform";
1010
import {createDevice} from "./test-utils";

Diff for: tests/app/tests/router.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {ROUTER_DIRECTIVES, Router, OnActivate, OnDeactivate, CanReuse, OnReuse,
2020
LocationStrategy, RouteParams, ComponentInstruction, RouteConfig, Location } from 'angular2/router';
2121
import {topmost, BackstackEntry} from "ui/frame";
2222
import {Page} from "ui/page";
23-
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "../nativescript-angular/router/ns-router";
23+
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router/ns-router";
2424

2525
@Component({
2626
template: `<StackLayout><Label text="Layout"></Label></StackLayout>`

Diff for: tests/app/tests/test-app.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//make sure you import mocha-config before angular2/core
2-
import {bootstrap, ProviderArray} from "../nativescript-angular/application";
2+
import {bootstrap, ProviderArray} from "nativescript-angular/application";
33
import {Type, Component, ComponentRef, DynamicComponentLoader,
44
ViewChild, ElementRef, provide, ApplicationRef
55
} from "angular2/core";
@@ -8,7 +8,7 @@ import {View} from "ui/core/view";
88
import {GridLayout} from "ui/layouts/grid-layout";
99
import {LayoutBase} from "ui/layouts/layout-base";
1010
import {topmost} from 'ui/frame';
11-
import {APP_ROOT_VIEW} from "../nativescript-angular/platform-providers";
11+
import {APP_ROOT_VIEW} from "nativescript-angular/platform-providers";
1212

1313
@Component({
1414
selector: 'my-app',

Diff for: tests/app/tests/value-accessor-tests.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import {DatePicker} from "ui/date-picker";
77
import {TimePicker} from "ui/time-picker";
88
import {ListPicker} from "ui/list-picker";
99
import {TextField} from "ui/text-field";
10-
import {NumberValueAccessor} from "../nativescript-angular/value-accessors/number-value-accessor";
11-
import {CheckedValueAccessor} from "../nativescript-angular/value-accessors/checked-value-accessor";
12-
import {DateValueAccessor} from "../nativescript-angular/value-accessors/date-value-accessor";
13-
import {TimeValueAccessor} from "../nativescript-angular/value-accessors/time-value-accessor";
14-
import {SelectedIndexValueAccessor} from "../nativescript-angular/value-accessors/selectedIndex-value-accessor";
15-
import {TextValueAccessor} from "../nativescript-angular/value-accessors/text-value-accessor";
10+
import {NumberValueAccessor} from "nativescript-angular/value-accessors/number-value-accessor";
11+
import {CheckedValueAccessor} from "nativescript-angular/value-accessors/checked-value-accessor";
12+
import {DateValueAccessor} from "nativescript-angular/value-accessors/date-value-accessor";
13+
import {TimeValueAccessor} from "nativescript-angular/value-accessors/time-value-accessor";
14+
import {SelectedIndexValueAccessor} from "nativescript-angular/value-accessors/selectedIndex-value-accessor";
15+
import {TextValueAccessor} from "nativescript-angular/value-accessors/text-value-accessor";
1616
import {ElementRef} from 'angular2/core';
1717

1818
class TestElementRef implements ElementRef {

Diff for: tests/hooks/before-prepare/10-copy-renderer.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
var path = require('path');
2-
var shelljs = require('shelljs');
1+
var execSync = require('child_process').execSync;
32

4-
module.exports = function ($logger, $projectData, $usbLiveSyncService) {
5-
var projectDir = path.join(__dirname, '..', '..');
6-
var appDir = path.join(projectDir, 'app');
7-
var srcDir = path.join(projectDir, '..', 'src');
3+
module.exports = function($logger, $projectData, $usbLiveSyncService) {
84
if (!$usbLiveSyncService.isInitialized) {
9-
shelljs.cp('-Rf', path.join(srcDir, 'nativescript-angular'), appDir);
10-
shelljs.cp('-Rf', path.join(srcDir, 'global.d.ts'), appDir);
5+
execSync("npm run updateTests", { stdio: [0, 1, 2]});
116
}
127
}

Diff for: tests/package.json

+59-55
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,61 @@
11
{
2-
"nativescript": {
3-
"id": "org.nativescript.helloworldng",
4-
"tns-android": {
5-
"version": "1.7.1"
6-
},
7-
"tns-ios": {
8-
"version": "1.7.0"
9-
}
10-
},
11-
"name": "nativescript-hello-world-ng",
12-
"main": "app.js",
13-
"version": "1.0.0",
14-
"author": "Telerik <[email protected]>",
15-
"description": "Nativescript Angular Hello World template",
16-
"license": "BSD",
17-
"keywords": [
18-
"telerik",
19-
"mobile",
20-
"angular",
21-
"nativescript",
22-
"{N}",
23-
"tns",
24-
"appbuilder",
25-
"template"
26-
],
27-
"repository": {
28-
"type": "git",
29-
"url": "git://github.com/NativeScript/template-hello-world-ng"
30-
},
31-
"homepage": "http://nativescript.org",
32-
"dependencies": {
33-
"tns-core-modules": "2.0.0-angular-2",
34-
"nativescript-intl": "^0.0.2",
35-
"angular2": "2.0.0-beta.9",
36-
"nativescript-unit-test-runner": "^0.3.3",
37-
"parse5": "1.4.2",
38-
"punycode": "1.3.2",
39-
"querystring": "0.2.0",
40-
"reflect-metadata": "0.1.2",
41-
"url": "0.10.3",
42-
"rxjs": "5.0.0-beta.2",
43-
"zone.js": "0.5.15"
44-
},
45-
"devDependencies": {
46-
"chai": "^3.5.0",
47-
"karma": "^0.13.19",
48-
"karma-chai": "^0.1.0",
49-
"karma-mocha": "^0.2.1",
50-
"karma-nativescript-launcher": "^0.4.0",
51-
"mocha": "^2.4.5",
52-
"karma-mocha-reporter": "^1.2.0",
53-
"nativescript-dev-typescript": "^0.3.1",
54-
"shelljs": "^0.5.3",
55-
"typescript": "1.8.2"
56-
}
2+
"nativescript": {
3+
"id": "org.nativescript.helloworldng",
4+
"tns-android": {
5+
"version": "1.7.1"
6+
},
7+
"tns-ios": {
8+
"version": "1.7.0"
9+
}
10+
},
11+
"name": "nativescript-hello-world-ng",
12+
"main": "app.js",
13+
"version": "1.0.0",
14+
"author": "Telerik <[email protected]>",
15+
"description": "Nativescript Angular Hello World template",
16+
"license": "BSD",
17+
"keywords": [
18+
"telerik",
19+
"mobile",
20+
"angular",
21+
"nativescript",
22+
"{N}",
23+
"tns",
24+
"appbuilder",
25+
"template"
26+
],
27+
"repository": {
28+
"type": "git",
29+
"url": "git://github.com/NativeScript/template-hello-world-ng"
30+
},
31+
"homepage": "http://nativescript.org",
32+
"dependencies": {
33+
"tns-core-modules": "2.0.0-angular-2",
34+
"nativescript-intl": "^0.0.2",
35+
"angular2": "2.0.0-beta.9",
36+
"nativescript-unit-test-runner": "^0.3.3",
37+
"parse5": "1.4.2",
38+
"punycode": "1.3.2",
39+
"querystring": "0.2.0",
40+
"reflect-metadata": "0.1.2",
41+
"url": "0.10.3",
42+
"rxjs": "5.0.0-beta.2",
43+
"zone.js": "0.5.15"
44+
},
45+
"devDependencies": {
46+
"chai": "^3.5.0",
47+
"grunt-cli": "^1.2.0",
48+
"karma": "^0.13.19",
49+
"karma-chai": "^0.1.0",
50+
"karma-mocha": "^0.2.1",
51+
"karma-mocha-reporter": "^1.2.0",
52+
"karma-nativescript-launcher": "^0.4.0",
53+
"mocha": "^2.4.5",
54+
"nativescript-dev-typescript": "^0.3.1",
55+
"shelljs": "^0.5.3",
56+
"typescript": "1.8.2"
57+
},
58+
"scripts" :{
59+
"updateTests" : "grunt updateTests"
60+
}
5761
}

0 commit comments

Comments
 (0)