1
1
/// <reference path=".d.ts" />
2
2
"use strict" ;
3
3
4
- import yok = require( '../lib/common/yok' ) ;
5
- import stubs = require( './stubs' ) ;
6
- import NpmLib = require( "../lib/node-package-manager" ) ;
7
- import FsLib = require( "../lib/common/file-system" ) ;
8
- import ProjectDataLib = require( "../lib/project-data" ) ;
9
- import ChildProcessLib = require( "../lib/common/child-process" ) ;
10
- import PlatformServiceLib = require( '../lib/services/platform-service' ) ;
11
- import OptionsLib = require( "../lib/options" ) ;
12
- import CommandsServiceLib = require( "../lib/common/services/commands-service" ) ;
13
- import StaticConfigLib = require( "../lib/config" ) ;
14
- import HostInfoLib = require( "../lib/common/host-info" ) ;
15
- import ErrorsLib = require( "../lib/common/errors" ) ;
16
- import ProjectHelperLib = require( "../lib/common/project-helper" ) ;
17
- import PlatformsDataLib = require( "../lib/platforms-data" ) ;
18
- import ProjectDataServiceLib = require( "../lib/services/project-data-service" ) ;
19
- import helpers = require( "../lib/common/helpers" ) ;
20
- import ProjectFilesManagerLib = require( "../lib/services/project-files-manager" ) ;
21
- import os = require( "os" ) ;
4
+ import { Yok } from '../lib/common/yok' ;
5
+ import * as stubs from './stubs' ;
6
+ import { NodePackageManager } from "../lib/node-package-manager" ;
7
+ import { FileSystem } from "../lib/common/file-system" ;
8
+ import { ProjectData } from "../lib/project-data" ;
9
+ import { ChildProcess } from "../lib/common/child-process" ;
10
+ import { PlatformService } from '../lib/services/platform-service' ;
11
+ import { Options } from "../lib/options" ;
12
+ import { CommandsService } from "../lib/common/services/commands-service" ;
13
+ import { StaticConfig } from "../lib/config" ;
14
+ import { HostInfo } from "../lib/common/host-info" ;
15
+ import { Errors } from "../lib/common/errors" ;
16
+ import { ProjectHelper } from "../lib/common/project-helper" ;
17
+ import { PlatformsData } from "../lib/platforms-data" ;
18
+ import { ProjectDataService } from "../lib/services/project-data-service" ;
19
+ import * as helpers from "../lib/common/helpers" ;
20
+ import { ProjectFilesManager } from "../lib/services/project-files-manager" ;
21
+ import { ResourceLoader } from "../lib/common/resource-loader" ;
22
+ import * as os from "os" ;
22
23
23
- import PluginsServiceLib = require ( "../lib/services/plugins-service" ) ;
24
- import AddPluginCommandLib = require ( "../lib/commands/plugin/add-plugin" ) ;
24
+ import { PluginsService } from "../lib/services/plugins-service" ;
25
+ import { AddPluginCommand } from "../lib/commands/plugin/add-plugin" ;
25
26
26
- import path = require ( "path" ) ;
27
- import temp = require ( "temp" ) ;
27
+ import * as path from "path" ;
28
+ import * as temp from "temp" ;
28
29
temp . track ( ) ;
29
30
30
31
let assert = require ( "chai" ) . assert ;
31
32
let isErrorThrown = false ;
32
33
33
34
function createTestInjector ( ) {
34
- let testInjector = new yok . Yok ( ) ;
35
+ let testInjector = new Yok ( ) ;
35
36
36
- testInjector . register ( "npm" , NpmLib . NodePackageManager ) ;
37
- testInjector . register ( "fs" , FsLib . FileSystem ) ;
38
- testInjector . register ( "projectData" , ProjectDataLib . ProjectData ) ;
37
+ testInjector . register ( "npm" , NodePackageManager ) ;
38
+ testInjector . register ( "fs" , FileSystem ) ;
39
+ testInjector . register ( "projectData" , ProjectData ) ;
39
40
testInjector . register ( "platforsmData" , stubs . PlatformsDataStub ) ;
40
- testInjector . register ( "childProcess" , ChildProcessLib . ChildProcess ) ;
41
- testInjector . register ( "platformService" , PlatformServiceLib . PlatformService ) ;
42
- testInjector . register ( "platformsData" , PlatformsDataLib . PlatformsData ) ;
41
+ testInjector . register ( "childProcess" , ChildProcess ) ;
42
+ testInjector . register ( "platformService" , PlatformService ) ;
43
+ testInjector . register ( "platformsData" , PlatformsData ) ;
43
44
testInjector . register ( "androidProjectService" , { } ) ;
44
45
testInjector . register ( "iOSProjectService" , { } ) ;
45
46
testInjector . register ( "devicesServices" , { } ) ;
46
- testInjector . register ( "projectDataService" , ProjectDataServiceLib . ProjectDataService ) ;
47
+ testInjector . register ( "projectDataService" , ProjectDataService ) ;
47
48
testInjector . register ( "prompter" , { } ) ;
49
+ testInjector . register ( "resources" , ResourceLoader ) ;
48
50
testInjector . register ( "broccoliBuilder" , { } ) ;
49
- testInjector . register ( "options" , OptionsLib . Options ) ;
50
- testInjector . register ( "errors" , ErrorsLib . Errors ) ;
51
+ testInjector . register ( "options" , Options ) ;
52
+ testInjector . register ( "errors" , Errors ) ;
51
53
testInjector . register ( "logger" , stubs . LoggerStub ) ;
52
- testInjector . register ( "staticConfig" , StaticConfigLib . StaticConfig ) ;
54
+ testInjector . register ( "staticConfig" , StaticConfig ) ;
53
55
testInjector . register ( "hooksService" , stubs . HooksServiceStub ) ;
54
- testInjector . register ( "commandsService" , CommandsServiceLib . CommandsService ) ;
56
+ testInjector . register ( "commandsService" , CommandsService ) ;
55
57
testInjector . register ( "commandsServiceProvider" , {
56
58
registerDynamicSubCommands : ( ) => { }
57
59
} ) ;
58
- testInjector . register ( "hostInfo" , HostInfoLib . HostInfo ) ;
60
+ testInjector . register ( "hostInfo" , HostInfo ) ;
59
61
testInjector . register ( "lockfile" , { } ) ;
60
- testInjector . register ( "projectHelper" , ProjectHelperLib . ProjectHelper ) ;
62
+ testInjector . register ( "projectHelper" , ProjectHelper ) ;
61
63
62
- testInjector . register ( "pluginsService" , PluginsServiceLib . PluginsService ) ;
64
+ testInjector . register ( "pluginsService" , PluginsService ) ;
63
65
testInjector . register ( "analyticsService" , {
64
66
trackException : ( ) => { return ( ( ) => { } ) . future < void > ( ) ( ) ; } ,
65
67
checkConsent : ( ) => { return ( ( ) => { } ) . future < void > ( ) ( ) ; } ,
66
68
trackFeature : ( ) => { return ( ( ) => { } ) . future < void > ( ) ( ) ; }
67
69
} ) ;
68
- testInjector . register ( "projectFilesManager" , ProjectFilesManagerLib . ProjectFilesManager ) ;
70
+ testInjector . register ( "projectFilesManager" , ProjectFilesManager ) ;
69
71
70
72
return testInjector ;
71
73
}
@@ -122,7 +124,7 @@ function addPluginWhenExpectingToFail(testInjector: IInjector, plugin: string, e
122
124
mockBeginCommand ( testInjector , "Exception: " + expectedErrorMessage ) ;
123
125
124
126
isErrorThrown = false ;
125
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
127
+ let commandsService = testInjector . resolve ( CommandsService ) ;
126
128
commandsService . tryExecuteCommand ( "plugin|add" , [ plugin ] ) . wait ( ) ;
127
129
128
130
assert . isTrue ( isErrorThrown ) ;
@@ -156,7 +158,7 @@ describe("Plugins service", () => {
156
158
let testInjector : IInjector ;
157
159
beforeEach ( ( ) => {
158
160
testInjector = createTestInjector ( ) ;
159
- testInjector . registerCommand ( "plugin|add" , AddPluginCommandLib . AddPluginCommand ) ;
161
+ testInjector . registerCommand ( "plugin|add" , AddPluginCommand ) ;
160
162
} ) ;
161
163
162
164
describe ( "plugin add" , ( ) => {
@@ -190,7 +192,7 @@ describe("Plugins service", () => {
190
192
mockBeginCommand ( testInjector , "Exception: " + 'Plugin "plugin1" is already installed.' ) ;
191
193
192
194
isErrorThrown = false ;
193
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
195
+ let commandsService = testInjector . resolve ( CommandsService ) ;
194
196
commandsService . tryExecuteCommand ( "plugin|add" , [ pluginName ] ) . wait ( ) ;
195
197
196
198
assert . isTrue ( isErrorThrown ) ;
@@ -263,7 +265,7 @@ describe("Plugins service", () => {
263
265
} ) . future < IPluginData [ ] > ( ) ( ) ;
264
266
}
265
267
266
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
268
+ let commandsService = testInjector . resolve ( CommandsService ) ;
267
269
commandsService . tryExecuteCommand ( "plugin|add" , [ pluginName ] ) . wait ( ) ;
268
270
269
271
let fs = testInjector . resolve ( "fs" ) ;
@@ -301,7 +303,7 @@ describe("Plugins service", () => {
301
303
} ) . future < IPluginData [ ] > ( ) ( ) ;
302
304
}
303
305
304
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
306
+ let commandsService = testInjector . resolve ( CommandsService ) ;
305
307
commandsService . tryExecuteCommand ( "plugin|add" , [ pluginName + "@1.0.0" ] ) . wait ( ) ;
306
308
307
309
let fs = testInjector . resolve ( "fs" ) ;
@@ -352,7 +354,7 @@ describe("Plugins service", () => {
352
354
} ) . future < IPluginData [ ] > ( ) ( ) ;
353
355
}
354
356
355
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
357
+ let commandsService = testInjector . resolve ( CommandsService ) ;
356
358
commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
357
359
358
360
// Assert that the all plugin's content is successfully added to node_modules folder
@@ -401,7 +403,7 @@ describe("Plugins service", () => {
401
403
let options = testInjector . resolve ( "options" ) ;
402
404
options . production = true ;
403
405
404
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
406
+ let commandsService = testInjector . resolve ( CommandsService ) ;
405
407
commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
406
408
407
409
let nodeModulesFolderPath = path . join ( projectFolder , "node_modules" ) ;
@@ -443,7 +445,7 @@ describe("Plugins service", () => {
443
445
let options = testInjector . resolve ( "options" ) ;
444
446
options . production = false ;
445
447
446
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
448
+ let commandsService = testInjector . resolve ( CommandsService ) ;
447
449
commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
448
450
} ) ;
449
451
} ) ;
@@ -452,7 +454,7 @@ describe("Plugins service", () => {
452
454
let testInjector : IInjector ;
453
455
beforeEach ( ( ) => {
454
456
testInjector = createTestInjector ( ) ;
455
- testInjector . registerCommand ( "plugin|add" , AddPluginCommandLib . AddPluginCommand ) ;
457
+ testInjector . registerCommand ( "plugin|add" , AddPluginCommand ) ;
456
458
} ) ;
457
459
it ( "fails if the plugin contains incorrect xml" , ( ) => {
458
460
let pluginName = "mySamplePlugin" ;
@@ -513,7 +515,7 @@ describe("Plugins service", () => {
513
515
`\n@#[line:1,col:39].` ;
514
516
mockBeginCommand ( testInjector , expectedErrorMessage ) ;
515
517
516
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
518
+ let commandsService = testInjector . resolve ( CommandsService ) ;
517
519
commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
518
520
} ) ;
519
521
it ( "merges AndroidManifest.xml and produces correct xml" , ( ) => {
0 commit comments