Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jul 17, 2019
1 parent eca174c commit b9d9352
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 99 deletions.
6 changes: 1 addition & 5 deletions commands/exec/__tests__/exec-command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,16 @@ describe("ExecCommand", () => {
const [logMessage] = loggingOutput("warn");
expect(logMessage).toMatch("Dependency cycles detected, you should fix these!");
expect(logMessage).toMatch("package-cycle-1 -> package-cycle-2 -> package-cycle-1");
expect(logMessage).toMatch("package-cycle-2 -> package-cycle-1 -> package-cycle-2");
expect(logMessage).toMatch(
"package-cycle-extraneous -> package-cycle-1 -> package-cycle-2 -> package-cycle-1"
);

expect(calledInPackages()).toEqual([
"package-dag-1",
"package-standalone",
"package-dag-2a",
"package-dag-2b",
"package-dag-3",
"package-cycle-1",
"package-cycle-2",
"package-cycle-extraneous",
"package-dag-3",
]);
});

Expand Down
32 changes: 27 additions & 5 deletions commands/run/__tests__/run-command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,45 @@ describe("RunCommand", () => {
const [logMessage] = loggingOutput("warn");
expect(logMessage).toMatch("Dependency cycles detected, you should fix these!");
expect(logMessage).toMatch("package-cycle-1 -> package-cycle-2 -> package-cycle-1");
expect(logMessage).toMatch("package-cycle-2 -> package-cycle-1 -> package-cycle-2");
expect(logMessage).toMatch(
"package-cycle-extraneous -> package-cycle-1 -> package-cycle-2 -> package-cycle-1"
);

expect(output.logged().split("\n")).toEqual([
"package-dag-1",
"package-standalone",
"package-dag-2a",
"package-dag-2b",
"package-dag-3",
"package-cycle-1",
"package-cycle-2",
"package-cycle-extraneous",
"package-dag-3",
]);
});

it("works with intersected cycles", async () => {
const testDir = await initFixture("cycle-intersection");

await lernaRun(testDir)("env");

const [logMessage] = loggingOutput("warn");
expect(logMessage).toMatch("Dependency cycles detected, you should fix these!");
expect(logMessage).toMatch("b -> c -> d -> e -> b");
expect(logMessage).toMatch("f -> g -> (nested cycle: b -> c -> d -> e -> b) -> f");

expect(output.logged().split("\n")).toEqual(["f", "b", "e", "d", "c", "g", "a"]);
});

it("works with separate cycles", async () => {
const testDir = await initFixture("cycle-separate");

await lernaRun(testDir)("env");

const [logMessage] = loggingOutput("warn");
expect(logMessage).toMatch("Dependency cycles detected, you should fix these!");
expect(logMessage).toMatch("b -> c -> d -> b");
expect(logMessage).toMatch("e -> f -> g -> e");

expect(output.logged().split("\n")).toEqual(["e", "g", "f", "h", "b", "d", "c", "a"]);
});

it("should throw an error with --reject-cycles", async () => {
const testDir = await initFixture("toposort");

Expand Down
2 changes: 1 addition & 1 deletion utils/listable/__tests__/listable-format.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ pkg-1
expect(loggingOutput("warn")).toContainEqual(expect.stringContaining("pkg-2 -> pkg-3 -> pkg-2"));
expect(text).toMatchInlineSnapshot(`
pkg-2
pkg-1
pkg-3 (PRIVATE)
pkg-1
`);
});
});
Expand Down
176 changes: 88 additions & 88 deletions utils/pack-directory/__tests__/pack-directory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,64 +91,64 @@ describe("pack-directory", () => {
const SHASUM_PATTERN = /[0-9a-f]{40}/;

expect(head).toMatchInlineSnapshot(`
Object {
"bundled": Array [],
"entryCount": 3,
"filename": "integration-package-1-1.0.0.tgz",
"files": Array [
{
"mode": "MODE",
"path": "package.json",
"size": 269,
},
{
"mode": "MODE",
"path": "build.js",
"size": 329,
},
{
"mode": "MODE",
"path": "index.src.js",
"size": 141,
},
],
"id": "@integration/package-1@1.0.0",
"integrity": "INTEGRITY",
"name": "@integration/package-1",
"shasum": "SHASUM",
"size": 539,
"tarFilePath": "__TAR_DIR__/integration-package-1-1.0.0.tgz",
"unpackedSize": 739,
"version": "1.0.0",
}
`);
Object {
"bundled": Array [],
"entryCount": 3,
"filename": "integration-package-1-1.0.0.tgz",
"files": Array [
{
"mode": "MODE",
"path": "package.json",
"size": 269,
},
{
"mode": "MODE",
"path": "build.js",
"size": 329,
},
{
"mode": "MODE",
"path": "index.src.js",
"size": 141,
},
],
"id": "@integration/package-1@1.0.0",
"integrity": "INTEGRITY",
"name": "@integration/package-1",
"shasum": "SHASUM",
"size": 539,
"tarFilePath": "__TAR_DIR__/integration-package-1-1.0.0.tgz",
"unpackedSize": 739,
"version": "1.0.0",
}
`);
// integrity is an instance of Integrity
// https://github.com/zkat/ssri/blob/a4337cd672f341deee2b52699b6720d82e4d0ddf/index.js#L83
expect(head.integrity.toString()).toMatch(INTEGRITY_PATTERN);
expect(head.shasum).toMatch(SHASUM_PATTERN);

expect(tail).toMatchInlineSnapshot(`
Object {
"bundled": Array [],
"entryCount": 1,
"filename": "package-4-1.0.0.tgz",
"files": Array [
{
"mode": "MODE",
"path": "package.json",
"size": 224,
},
],
"id": "package-4@1.0.0",
"integrity": "INTEGRITY",
"name": "package-4",
"shasum": "SHASUM",
"size": 230,
"tarFilePath": "__TAR_DIR__/package-4-1.0.0.tgz",
"unpackedSize": 224,
"version": "1.0.0",
}
`);
Object {
"bundled": Array [],
"entryCount": 1,
"filename": "package-4-1.0.0.tgz",
"files": Array [
{
"mode": "MODE",
"path": "package.json",
"size": 224,
},
],
"id": "package-4@1.0.0",
"integrity": "INTEGRITY",
"name": "package-4",
"shasum": "SHASUM",
"size": 230,
"tarFilePath": "__TAR_DIR__/package-4-1.0.0.tgz",
"unpackedSize": 224,
"version": "1.0.0",
}
`);
expect(tail.integrity.toString()).toMatch(INTEGRITY_PATTERN);
expect(tail.shasum).toMatch(SHASUM_PATTERN);

Expand All @@ -175,41 +175,41 @@ Object {
);

expect(lazy).toMatchInlineSnapshot(`
Object {
"bundled": Array [],
"entryCount": 4,
"filename": "package-3-1.0.0.tgz",
"files": Array [
{
"mode": "MODE",
"path": "package.json",
"size": 455,
},
{
"mode": "MODE",
"path": "cli1.js",
"size": 108,
},
{
"mode": "MODE",
"path": "cli2.js",
"size": 108,
},
{
"mode": "MODE",
"path": "index.js",
"size": 25,
},
],
"id": "package-3@1.0.0",
"integrity": "INTEGRITY",
"name": "package-3",
"shasum": "SHASUM",
"size": 446,
"tarFilePath": "__TAR_DIR__/package-3-1.0.0.tgz",
"unpackedSize": 696,
"version": "1.0.0",
}
`);
Object {
"bundled": Array [],
"entryCount": 4,
"filename": "package-3-1.0.0.tgz",
"files": Array [
{
"mode": "MODE",
"path": "package.json",
"size": 455,
},
{
"mode": "MODE",
"path": "cli1.js",
"size": 108,
},
{
"mode": "MODE",
"path": "cli2.js",
"size": 108,
},
{
"mode": "MODE",
"path": "index.js",
"size": 25,
},
],
"id": "package-3@1.0.0",
"integrity": "INTEGRITY",
"name": "package-3",
"shasum": "SHASUM",
"size": 449,
"tarFilePath": "__TAR_DIR__/package-3-1.0.0.tgz",
"unpackedSize": 696,
"version": "1.0.0",
}
`);
});
});

0 comments on commit b9d9352

Please sign in to comment.