11/// <reference path=".d.ts" />
22"use strict" ;
33
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 { EOL } from "os" ;
22- import PluginsServiceLib = require( "../lib/services/plugins-service" ) ;
23- import AddPluginCommandLib = require( "../lib/commands/plugin/add-plugin" ) ;
24- import { assert } from "chai" ;
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 { EOL } from "os" ;
23+
24+ import { PluginsService } from "../lib/services/plugins-service" ;
25+ import { AddPluginCommand } from "../lib/commands/plugin/add-plugin" ;
26+
27+ import { assert } from "chai"
2528import * as path from "path" ;
2629import * as temp from "temp" ;
2730temp . track ( ) ;
2831
2932let isErrorThrown = false ;
3033
3134function createTestInjector ( ) {
32- let testInjector = new yok . Yok ( ) ;
35+ let testInjector = new Yok ( ) ;
3336
34- testInjector . register ( "npm" , NpmLib . NodePackageManager ) ;
35- testInjector . register ( "fs" , FsLib . FileSystem ) ;
36- testInjector . register ( "projectData" , ProjectDataLib . ProjectData ) ;
37+ testInjector . register ( "npm" , NodePackageManager ) ;
38+ testInjector . register ( "fs" , FileSystem ) ;
39+ testInjector . register ( "projectData" , ProjectData ) ;
3740 testInjector . register ( "platforsmData" , stubs . PlatformsDataStub ) ;
38- testInjector . register ( "childProcess" , ChildProcessLib . ChildProcess ) ;
39- testInjector . register ( "platformService" , PlatformServiceLib . PlatformService ) ;
40- testInjector . register ( "platformsData" , PlatformsDataLib . PlatformsData ) ;
41+ testInjector . register ( "childProcess" , ChildProcess ) ;
42+ testInjector . register ( "platformService" , PlatformService ) ;
43+ testInjector . register ( "platformsData" , PlatformsData ) ;
4144 testInjector . register ( "androidProjectService" , { } ) ;
4245 testInjector . register ( "iOSProjectService" , { } ) ;
4346 testInjector . register ( "devicesServices" , { } ) ;
44- testInjector . register ( "projectDataService" , ProjectDataServiceLib . ProjectDataService ) ;
47+ testInjector . register ( "projectDataService" , ProjectDataService ) ;
4548 testInjector . register ( "prompter" , { } ) ;
49+ testInjector . register ( "resources" , ResourceLoader ) ;
4650 testInjector . register ( "broccoliBuilder" , { } ) ;
47- testInjector . register ( "options" , OptionsLib . Options ) ;
48- testInjector . register ( "errors" , ErrorsLib . Errors ) ;
51+ testInjector . register ( "options" , Options ) ;
52+ testInjector . register ( "errors" , Errors ) ;
4953 testInjector . register ( "logger" , stubs . LoggerStub ) ;
50- testInjector . register ( "staticConfig" , StaticConfigLib . StaticConfig ) ;
54+ testInjector . register ( "staticConfig" , StaticConfig ) ;
5155 testInjector . register ( "hooksService" , stubs . HooksServiceStub ) ;
52- testInjector . register ( "commandsService" , CommandsServiceLib . CommandsService ) ;
56+ testInjector . register ( "commandsService" , CommandsService ) ;
5357 testInjector . register ( "commandsServiceProvider" , {
5458 registerDynamicSubCommands : ( ) => { }
5559 } ) ;
56- testInjector . register ( "hostInfo" , HostInfoLib . HostInfo ) ;
60+ testInjector . register ( "hostInfo" , HostInfo ) ;
5761 testInjector . register ( "lockfile" , { } ) ;
58- testInjector . register ( "projectHelper" , ProjectHelperLib . ProjectHelper ) ;
62+ testInjector . register ( "projectHelper" , ProjectHelper ) ;
5963
60- testInjector . register ( "pluginsService" , PluginsServiceLib . PluginsService ) ;
64+ testInjector . register ( "pluginsService" , PluginsService ) ;
6165 testInjector . register ( "analyticsService" , {
6266 trackException : ( ) => { return ( ( ) => { } ) . future < void > ( ) ( ) ; } ,
6367 checkConsent : ( ) => { return ( ( ) => { } ) . future < void > ( ) ( ) ; } ,
6468 trackFeature : ( ) => { return ( ( ) => { } ) . future < void > ( ) ( ) ; }
6569 } ) ;
66- testInjector . register ( "projectFilesManager" , ProjectFilesManagerLib . ProjectFilesManager ) ;
70+ testInjector . register ( "projectFilesManager" , ProjectFilesManager ) ;
6771
6872 return testInjector ;
6973}
@@ -120,7 +124,7 @@ function addPluginWhenExpectingToFail(testInjector: IInjector, plugin: string, e
120124 mockBeginCommand ( testInjector , "Exception: " + expectedErrorMessage ) ;
121125
122126 isErrorThrown = false ;
123- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
127+ let commandsService = testInjector . resolve ( CommandsService ) ;
124128 commandsService . tryExecuteCommand ( "plugin|add" , [ plugin ] ) . wait ( ) ;
125129
126130 assert . isTrue ( isErrorThrown ) ;
@@ -154,7 +158,7 @@ describe("Plugins service", () => {
154158 let testInjector : IInjector ;
155159 beforeEach ( ( ) => {
156160 testInjector = createTestInjector ( ) ;
157- testInjector . registerCommand ( "plugin|add" , AddPluginCommandLib . AddPluginCommand ) ;
161+ testInjector . registerCommand ( "plugin|add" , AddPluginCommand ) ;
158162 } ) ;
159163
160164 describe ( "plugin add" , ( ) => {
@@ -188,7 +192,7 @@ describe("Plugins service", () => {
188192 mockBeginCommand ( testInjector , "Exception: " + 'Plugin "plugin1" is already installed.' ) ;
189193
190194 isErrorThrown = false ;
191- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
195+ let commandsService = testInjector . resolve ( CommandsService ) ;
192196 commandsService . tryExecuteCommand ( "plugin|add" , [ pluginName ] ) . wait ( ) ;
193197
194198 assert . isTrue ( isErrorThrown ) ;
@@ -260,7 +264,8 @@ describe("Plugins service", () => {
260264 } ) . future < IPluginData [ ] > ( ) ( ) ;
261265 } ;
262266
263- pluginsService . add ( pluginName ) . wait ( ) ;
267+ let commandsService = testInjector . resolve ( CommandsService ) ;
268+ commandsService . tryExecuteCommand ( "plugin|add" , [ pluginName ] ) . wait ( ) ;
264269
265270 let fs = testInjector . resolve ( "fs" ) ;
266271
@@ -296,7 +301,8 @@ describe("Plugins service", () => {
296301 } ) . future < IPluginData [ ] > ( ) ( ) ;
297302 } ;
298303
299- pluginsService . add ( pluginName + "@1.0.0" ) . wait ( ) ;
304+ let commandsService = testInjector . resolve ( CommandsService ) ;
305+ commandsService . tryExecuteCommand ( "plugin|add" , [ pluginName + "@1.0.0" ] ) . wait ( ) ;
300306
301307 let fs = testInjector . resolve ( "fs" ) ;
302308
@@ -345,7 +351,8 @@ describe("Plugins service", () => {
345351 } ) . future < IPluginData [ ] > ( ) ( ) ;
346352 } ;
347353
348- pluginsService . add ( pluginFolderPath ) . wait ( ) ;
354+ let commandsService = testInjector . resolve ( CommandsService ) ;
355+ commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
349356
350357 // Assert that the all plugin's content is successfully added to node_modules folder
351358 let nodeModulesFolderPath = path . join ( projectFolder , "node_modules" ) ;
@@ -393,7 +400,8 @@ describe("Plugins service", () => {
393400 let options = testInjector . resolve ( "options" ) ;
394401 options . production = true ;
395402
396- pluginsService . add ( pluginFolderPath ) . wait ( ) ;
403+ let commandsService = testInjector . resolve ( CommandsService ) ;
404+ commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
397405
398406 let nodeModulesFolderPath = path . join ( projectFolder , "node_modules" ) ;
399407 assert . isFalse ( fs . exists ( path . join ( nodeModulesFolderPath , pluginName , "node_modules" , "grunt" ) ) . wait ( ) ) ;
@@ -434,7 +442,7 @@ describe("Plugins service", () => {
434442 let options = testInjector . resolve ( "options" ) ;
435443 options . production = false ;
436444
437- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
445+ let commandsService = testInjector . resolve ( CommandsService ) ;
438446 commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
439447 } ) ;
440448 } ) ;
@@ -443,7 +451,7 @@ describe("Plugins service", () => {
443451 let testInjector : IInjector ;
444452 beforeEach ( ( ) => {
445453 testInjector = createTestInjector ( ) ;
446- testInjector . registerCommand ( "plugin|add" , AddPluginCommandLib . AddPluginCommand ) ;
454+ testInjector . registerCommand ( "plugin|add" , AddPluginCommand ) ;
447455 } ) ;
448456 it ( "fails if the plugin contains incorrect xml" , ( ) => {
449457 let pluginName = "mySamplePlugin" ;
@@ -504,7 +512,7 @@ describe("Plugins service", () => {
504512 `\n@#[line:1,col:39].` ;
505513 mockBeginCommand ( testInjector , expectedErrorMessage ) ;
506514
507- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
515+ let commandsService = testInjector . resolve ( CommandsService ) ;
508516 commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
509517 } ) ;
510518 it ( "merges AndroidManifest.xml and produces correct xml" , ( ) => {
0 commit comments