@@ -88,15 +88,10 @@ function createProject(testInjector: IInjector, dependencies?: any): string {
88
88
return tempFolder ;
89
89
}
90
90
91
- describe ( "Npm support tests" , ( ) => {
92
- it ( "Ensures that the installed dependencies are prepared correctly" , ( ) => {
93
- let dependencies = {
94
- "bplist" : "0.0.4" ,
95
- "lodash" : "3.9.3"
96
- } ;
97
-
91
+ function setupProject ( ) : IFuture < any > {
92
+ return ( ( ) => {
98
93
let testInjector = createTestInjector ( ) ;
99
- let projectFolder = createProject ( testInjector , dependencies ) ;
94
+ let projectFolder = createProject ( testInjector ) ;
100
95
101
96
let fs = testInjector . resolve ( "fs" ) ;
102
97
@@ -112,7 +107,6 @@ describe("Npm support tests", () => {
112
107
let androidFolderPath = path . join ( projectFolder , "platforms" , "android" ) ;
113
108
fs . ensureDirectoryExists ( androidFolderPath ) . wait ( ) ;
114
109
115
-
116
110
// Mock platform data
117
111
let appDestinationFolderPath = path . join ( androidFolderPath , "assets" ) ;
118
112
let platformsData = testInjector . resolve ( "platformsData" ) ;
@@ -129,8 +123,45 @@ describe("Npm support tests", () => {
129
123
}
130
124
} ;
131
125
132
- let platformService = testInjector . resolve ( "platformService" ) ;
133
- platformService . preparePlatform ( "android" ) . wait ( ) ;
126
+ return {
127
+ testInjector : testInjector ,
128
+ projectFolder : projectFolder ,
129
+ appDestinationFolderPath : appDestinationFolderPath ,
130
+ } ;
131
+ } ) . future < any > ( ) ( ) ;
132
+ }
133
+
134
+ function addDependencies ( testInjector : IInjector , projectFolder : string , dependencies : any ) : IFuture < void > {
135
+ return ( ( ) => {
136
+ let fs = testInjector . resolve ( "fs" ) ;
137
+ let packageJsonPath = path . join ( projectFolder , "package.json" ) ;
138
+ let packageJsonData = fs . readJson ( packageJsonPath ) . wait ( ) ;
139
+
140
+ let currentDependencies = packageJsonData . dependencies ;
141
+ _ . extend ( currentDependencies , dependencies ) ;
142
+ fs . writeJson ( packageJsonPath , packageJsonData ) . wait ( ) ;
143
+ } ) . future < void > ( ) ( ) ;
144
+ }
145
+
146
+ function preparePlatform ( testInjector : IInjector ) : IFuture < void > {
147
+ let platformService = testInjector . resolve ( "platformService" ) ;
148
+ return platformService . preparePlatform ( "android" ) ;
149
+ }
150
+
151
+ describe ( "Npm support tests" , ( ) => {
152
+ let testInjector : IInjector , projectFolder : string , appDestinationFolderPath : string ;
153
+ before ( ( ) => {
154
+ let projectSetup = setupProject ( ) . wait ( ) ;
155
+ testInjector = projectSetup . testInjector ;
156
+ projectFolder = projectSetup . projectFolder ;
157
+ appDestinationFolderPath = projectSetup . appDestinationFolderPath ;
158
+ } ) ;
159
+ it ( "Ensures that the installed dependencies are prepared correctly" , ( ) => {
160
+ // Setup
161
+ addDependencies ( testInjector , projectFolder , { "bplist" : "0.0.4" } ) . wait ( ) ;
162
+
163
+ // Act
164
+ preparePlatform ( testInjector ) . wait ( ) ;
134
165
135
166
// Assert
136
167
let tnsModulesFolderPath = path . join ( appDestinationFolderPath , "app" , "tns_modules" ) ;
@@ -139,6 +170,7 @@ describe("Npm support tests", () => {
139
170
let bplistCreatorFolderPath = path . join ( tnsModulesFolderPath , "bplist-creator" ) ;
140
171
let bplistParserFolderPath = path . join ( tnsModulesFolderPath , "bplist-parser" ) ;
141
172
173
+ let fs = testInjector . resolve ( "fs" ) ;
142
174
assert . isTrue ( fs . exists ( lodashFolderPath ) . wait ( ) ) ;
143
175
assert . isTrue ( fs . exists ( bplistFolderPath ) . wait ( ) ) ;
144
176
assert . isTrue ( fs . exists ( bplistCreatorFolderPath ) . wait ( ) ) ;
0 commit comments