Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
tests for main.js that is not in the commonPrefix (to guarantee that …
Browse files Browse the repository at this point in the history
…we have a main

at the top level of the extension)
  • Loading branch information
dangoor committed Mar 19, 2013
1 parent 828a264 commit 17e9b6a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/extensibility/node/ExtensionManagerDomain.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function _cmdValidate(path, callback) {
}
var callbackCalled = false;
var metadata;
var foundMain = false;
var foundMainIn = null;
var errors = [];
var commonPrefix = null;

Expand Down Expand Up @@ -183,7 +183,7 @@ function _cmdValidate(path, callback) {
}
});
} else if (fileName === "main.js") {
foundMain = true;
foundMainIn = commonPrefix;
}
})
.on("end", function () {
Expand All @@ -195,7 +195,7 @@ function _cmdValidate(path, callback) {
return;
}

if (!foundMain) {
if (foundMainIn === null || foundMainIn !== commonPrefix) {
errors.push([Errors.MISSING_MAIN, path]);
}

Expand Down
11 changes: 11 additions & 0 deletions src/extensibility/node/spec/Validation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var basicValidExtension = path.join(testFilesDirectory, "basic-valid-extension.z
oneLevelDown = path.join(testFilesDirectory, "one-level-extension-master.zip"),
bogusTopDir = path.join(testFilesDirectory, "bogus-top-dir.zip"),
badname = path.join(testFilesDirectory, "badname.zip"),
mainInDirectory = path.join(testFilesDirectory, "main-in-directory.zip"),
invalidVersion = path.join(testFilesDirectory, "invalid-version.zip");

describe("Package Validation", function () {
Expand Down Expand Up @@ -168,4 +169,14 @@ describe("Package Validation", function () {
done();
});
});

it("should complain about files that don't have main in the top dir", function (done) {
ExtensionsDomain._cmdValidate(mainInDirectory, function (err, result) {
expect(err).toBeNull();
var errors = result.errors;
expect(errors.length).toEqual(1);
expect(errors[0][0]).toEqual("MISSING_MAIN");
done();
});
});
});
Binary file added test/spec/extension-test-files/main-in-directory.zip
Binary file not shown.

0 comments on commit 17e9b6a

Please sign in to comment.