Skip to content

Commit

Permalink
Update tests that were introduced while PR was in-flight
Browse files Browse the repository at this point in the history
  • Loading branch information
gigabo committed Dec 14, 2016
1 parent 3798ddf commit af4a738
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 36 deletions.
24 changes: 12 additions & 12 deletions test/BootstrapCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,38 +279,38 @@ describe("BootstrapCommand", () => {
assert.throws(() => fs.readlinkSync(path.join(testDir, "packages", "package-2", "node_modules", "package-4")));
// package-3 package dependencies are symlinked
assert.equal(
fs.readlinkSync(path.join(testDir, "package-3", "node_modules", "@test", "package-1")),
path.join(testDir, "packages", "package-1"),
normalize(fs.readlinkSync(path.join(testDir, "package-3", "node_modules", "@test", "package-1"))),
normalize(path.join(testDir, "packages", "package-1")),
"package-1 should be symlinked to package-3"
);
assert.equal(
fs.readlinkSync(path.join(testDir, "package-3", "node_modules", "package-2")),
path.join(testDir, "packages", "package-2"),
normalize(fs.readlinkSync(path.join(testDir, "package-3", "node_modules", "package-2"))),
normalize(path.join(testDir, "packages", "package-2")),
"package-2 should be symlinked to package-3"
);
assert.throws(() => fs.readlinkSync(path.join(testDir, "package-3", "node_modules", "package-4")));
// package-4 package dependencies are symlinked
assert.throws(() => fs.readlinkSync(path.join(testDir, "packages", "package-4", "node_modules", "package-1")));
assert.throws(() => fs.readlinkSync(path.join(testDir, "packages", "package-4", "node_modules", "package-2")));
assert.equal(
fs.readlinkSync(path.join(testDir, "packages", "package-4", "node_modules", "package-3")),
path.join(testDir, "package-3"),
normalize(fs.readlinkSync(path.join(testDir, "packages", "package-4", "node_modules", "package-3"))),
normalize(path.join(testDir, "package-3")),
"package-3 should be symlinked to package-4"
);
// package binaries are symlinked
assert.equal(
fs.readlinkSync(path.join(testDir, "package-3", "node_modules", ".bin", "package-2")),
path.join(testDir, "packages", "package-2", "cli.js"),
normalize(FileSystemUtilities.isSymlink(path.join(testDir, "package-3", "node_modules", ".bin", "package-2"))),
normalize(path.join(testDir, "packages", "package-2", "cli.js")),
"package-2 binary should be symlinked in package-3"
);
assert.equal(
fs.readlinkSync(path.join(testDir, "packages", "package-4", "node_modules", ".bin", "package3cli1")),
path.join(testDir, "package-3", "cli1.js"),
normalize(FileSystemUtilities.isSymlink(path.join(testDir, "packages", "package-4", "node_modules", ".bin", "package3cli1"))),
normalize(path.join(testDir, "package-3", "cli1.js")),
"package-3 binary should be symlinked in package-4"
);
assert.equal(
fs.readlinkSync(path.join(testDir, "packages", "package-4", "node_modules", ".bin", "package3cli2")),
path.join(testDir, "package-3", "cli2.js"),
normalize(FileSystemUtilities.isSymlink(path.join(testDir, "packages", "package-4", "node_modules", ".bin", "package3cli2"))),
normalize(path.join(testDir, "package-3", "cli2.js")),
"package-3 binary should be symlinked in package-4"
);
done();
Expand Down
41 changes: 21 additions & 20 deletions test/LsCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ describe("LsCommand", () => {

lsCommand.runCommand(exitWithCode(0, done));
});


// Both of these commands should result in the same outcome
const filters = [
{ test: "should list changes for a given scope", flag: "scope", flagValue: "package-1"},
{ test: "should not list changes for ignored packages", flag: "ignore", flagValue: "package-@(2|3|4|5)"},
];
filters.forEach((filter) => {
it(filter.test, (done) => {
const lsCommand = new LsCommand([], {[filter.flag]: filter.flagValue});

lsCommand.runValidations();
lsCommand.runPreparations();

stub(logger, "info", (message) => {
assert.equal(message, "- package-1");
});

lsCommand.runCommand(exitWithCode(0, done));
});
});
});

describe("in a repo with packages outside of packages/", () => {
Expand All @@ -46,24 +67,4 @@ describe("LsCommand", () => {
lsCommand.runCommand(exitWithCode(0, done));
});
});

// Both of these commands should result in the same outcome
const filters = [
{ test: "should list changes for a given scope", flag: "scope", flagValue: "package-1"},
{ test: "should not list changes for ignored packages", flag: "ignore", flagValue: "package-@(2|3|4|5)"},
];
filters.forEach((filter) => {
it(filter.test, (done) => {
const lsCommand = new LsCommand([], {[filter.flag]: filter.flagValue});

lsCommand.runValidations();
lsCommand.runPreparations();

stub(logger, "info", (message) => {
assert.equal(message, "- package-1");
});

lsCommand.runCommand(exitWithCode(0, done));
});
});
});
20 changes: 16 additions & 4 deletions test/PackageUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,14 @@ describe("PackageUtilities", () => {
});

describe(".topologicallyBatchPackages()", () => {
const fixture = path.join(__dirname, "fixtures/PackageUtilities/toposort/packages");
const packages = PackageUtilities.getPackages(fixture);
let packages;

beforeEach((done) => {
initFixture("PackageUtilities/toposort", () => {
packages = PackageUtilities.getPackages(new Repository);
done();
});
});

it("should batch roots, then internal/leaf nodes, then cycles", () => {
assert.deepEqual(
Expand All @@ -134,8 +140,14 @@ describe("PackageUtilities", () => {
});

describe(".filterPackages()", () => {
const fixture = path.join(__dirname, "fixtures/PackageUtilities/filtering/packages");
const packages = PackageUtilities.getPackages(fixture);
let packages;

beforeEach((done) => {
initFixture("PackageUtilities/filtering", () => {
packages = PackageUtilities.getPackages(new Repository);
done();
});
});

it("should filter --scoped packages", () => {
const flags = { scope: "package-a-*"};
Expand Down

0 comments on commit af4a738

Please sign in to comment.