@@ -191,6 +191,7 @@ describe("Npm support tests", () => {
191
191
appDestinationFolderPath = projectSetup . appDestinationFolderPath ;
192
192
} ) ;
193
193
it ( "Ensures that the installed dependencies are prepared correctly" , ( ) => {
194
+ let fs : IFileSystem = testInjector . resolve ( "fs" ) ;
194
195
// Setup
195
196
addDependencies ( testInjector , projectFolder , { "bplist" : "0.0.4" } ) . wait ( ) ;
196
197
@@ -199,16 +200,15 @@ describe("Npm support tests", () => {
199
200
200
201
// Assert
201
202
let tnsModulesFolderPath = path . join ( appDestinationFolderPath , "app" , "tns_modules" ) ;
202
- let lodashFolderPath = path . join ( tnsModulesFolderPath , "lodash" ) ;
203
- let bplistFolderPath = path . join ( tnsModulesFolderPath , "bplist" ) ;
204
- let bplistCreatorFolderPath = path . join ( tnsModulesFolderPath , "bplist-creator" ) ;
205
- let bplistParserFolderPath = path . join ( tnsModulesFolderPath , "bplist-parser" ) ;
206
203
207
- let fs = testInjector . resolve ( "fs" ) ;
208
- assert . isTrue ( fs . exists ( lodashFolderPath ) . wait ( ) ) ;
209
- assert . isTrue ( fs . exists ( bplistFolderPath ) . wait ( ) ) ;
210
- assert . isTrue ( fs . exists ( bplistCreatorFolderPath ) . wait ( ) ) ;
211
- assert . isTrue ( fs . exists ( bplistParserFolderPath ) . wait ( ) ) ;
204
+ let results = fs . enumerateFilesInDirectorySync ( tnsModulesFolderPath , ( file , stat ) => {
205
+ return true ;
206
+ } , { enumerateDirectories : true } ) ;
207
+
208
+ assert . isTrue ( results . filter ( ( val ) => _ . endsWith ( val , "lodash" ) ) . length === 1 ) ;
209
+ assert . isTrue ( results . filter ( ( val ) => _ . endsWith ( val , path . join ( tnsModulesFolderPath , "bplist" ) ) ) . length === 1 ) ;
210
+ assert . isTrue ( results . filter ( ( val ) => _ . endsWith ( val , "bplist-creator" ) ) . length === 1 ) ;
211
+ assert . isTrue ( results . filter ( ( val ) => _ . endsWith ( val , "bplist-parser" ) ) . length === 1 ) ;
212
212
} ) ;
213
213
it ( "Ensures that scoped dependencies are prepared correctly" , ( ) => {
214
214
// Setup
@@ -219,11 +219,8 @@ describe("Npm support tests", () => {
219
219
let dependencies : any = { } ;
220
220
dependencies [ scopedName ] = "0.0.0-prealpha.3" ;
221
221
// Do not pass dependencies object as the sinopia cannot work with scoped dependencies. Instead move them manually.
222
- addDependencies ( testInjector , projectFolder , { } ) . wait ( ) ;
223
- //create module dir, and add a package.json
224
- shelljs . mkdir ( "-p" , scopedModule ) ;
225
- fs . writeFile ( scopedPackageJson , JSON . stringify ( { name : scopedName , version : "1.0.0" } ) ) . wait ( ) ;
226
-
222
+ addDependencies ( testInjector , projectFolder , dependencies ) . wait ( ) ;
223
+
227
224
// Act
228
225
preparePlatform ( testInjector ) . wait ( ) ;
229
226
@@ -249,9 +246,16 @@ describe("Npm support tests", () => {
249
246
250
247
// Assert
251
248
let tnsModulesFolderPath = path . join ( appDestinationFolderPath , "app" , "tns_modules" ) ;
249
+
250
+ let results = fs . enumerateFilesInDirectorySync ( tnsModulesFolderPath , ( file , stat ) => {
251
+ return true ;
252
+ } , { enumerateDirectories : true } ) ;
252
253
253
- let scopedDependencyPath = path . join ( tnsModulesFolderPath , "@scoped-plugin" , "inner-plugin" ) ;
254
- assert . isTrue ( fs . exists ( scopedDependencyPath ) . wait ( ) ) ;
254
+ let filteredResults = results . filter ( ( val ) => {
255
+ return _ . endsWith ( val , path . join ( "@scoped-plugin" , "inner-plugin" ) ) ;
256
+ } ) ;
257
+
258
+ assert . isTrue ( filteredResults . length === 1 ) ;
255
259
} ) ;
256
260
257
261
it ( "Ensures that tns_modules absent when bundling" , ( ) => {
0 commit comments