Skip to content

Commit 6b8c084

Browse files
committed
fix broken tests
1 parent 77f86a3 commit 6b8c084

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

test/npm-support.ts

+20-16
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ describe("Npm support tests", () => {
191191
appDestinationFolderPath = projectSetup.appDestinationFolderPath;
192192
});
193193
it("Ensures that the installed dependencies are prepared correctly", () => {
194+
let fs: IFileSystem = testInjector.resolve("fs");
194195
// Setup
195196
addDependencies(testInjector, projectFolder, { "bplist": "0.0.4" }).wait();
196197

@@ -199,16 +200,15 @@ describe("Npm support tests", () => {
199200

200201
// Assert
201202
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");
206203

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);
212212
});
213213
it("Ensures that scoped dependencies are prepared correctly", () => {
214214
// Setup
@@ -219,11 +219,8 @@ describe("Npm support tests", () => {
219219
let dependencies: any = {};
220220
dependencies[scopedName] = "0.0.0-prealpha.3";
221221
// 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+
227224
// Act
228225
preparePlatform(testInjector).wait();
229226

@@ -249,9 +246,16 @@ describe("Npm support tests", () => {
249246

250247
// Assert
251248
let tnsModulesFolderPath = path.join(appDestinationFolderPath, "app", "tns_modules");
249+
250+
let results = fs.enumerateFilesInDirectorySync(tnsModulesFolderPath, (file, stat) => {
251+
return true;
252+
}, { enumerateDirectories: true });
252253

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);
255259
});
256260

257261
it("Ensures that tns_modules absent when bundling", () => {

0 commit comments

Comments
 (0)