Skip to content

Commit d180a80

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

16 files changed

+62
-46
lines changed

.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({

tests/app/tests/property-sets.ts

Lines changed: 3 additions & 3 deletions
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";

tests/app/tests/router.ts

Lines changed: 1 addition & 1 deletion
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>`

tests/app/tests/test-app.ts

Lines changed: 2 additions & 2 deletions
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',

tests/app/tests/value-accessor-tests.ts

Lines changed: 6 additions & 6 deletions
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 {
Lines changed: 3 additions & 8 deletions
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
}

tests/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@
4444
},
4545
"devDependencies": {
4646
"chai": "^3.5.0",
47+
"grunt-cli": "^1.2.0",
4748
"karma": "^0.13.19",
4849
"karma-chai": "^0.1.0",
4950
"karma-mocha": "^0.2.1",
51+
"karma-mocha-reporter": "^1.2.0",
5052
"karma-nativescript-launcher": "^0.4.0",
5153
"mocha": "^2.4.5",
52-
"karma-mocha-reporter": "^1.2.0",
5354
"nativescript-dev-typescript": "^0.3.1",
5455
"shelljs": "^0.5.3",
5556
"typescript": "1.8.2"
57+
},
58+
"scripts" :{
59+
"updateTests" : "grunt updateTests"
5660
}
57-
}
61+
}

0 commit comments

Comments
 (0)