Skip to content

Commit

Permalink
Add wrong test
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jul 16, 2019
1 parent ce58d8f commit e5917a0
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 13 deletions.
13 changes: 13 additions & 0 deletions __fixtures__/cycle-parent/graph.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
https://github.com/lerna/lerna/issues/2107#issuecomment-511987691

+---+
/----> | B |
| +---+
|
+---+ +---+ <----\
| A | --> | C | |
+---+ +---+ <-\ |
| | |
| +---+ <-/ |
\----> | D | |
+---+ <----/
3 changes: 3 additions & 0 deletions __fixtures__/cycle-parent/lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "1.0.0"
}
3 changes: 3 additions & 0 deletions __fixtures__/cycle-parent/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "babel-bug"
}
9 changes: 9 additions & 0 deletions __fixtures__/cycle-parent/packages/a/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "a",
"version": "1.0.0",
"dependencies": {
"b": "^1.0.0",
"c": "^1.0.0",
"d": "^1.0.0"
}
}
4 changes: 4 additions & 0 deletions __fixtures__/cycle-parent/packages/b/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "b",
"version": "1.0.0"
}
7 changes: 7 additions & 0 deletions __fixtures__/cycle-parent/packages/c/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "c",
"version": "1.0.0",
"dependencies": {
"d": "^1.0.0"
}
}
7 changes: 7 additions & 0 deletions __fixtures__/cycle-parent/packages/d/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "d",
"version": "1.0.0",
"dependencies": {
"c": "^1.0.0"
}
}
2 changes: 1 addition & 1 deletion __fixtures__/toposort/lerna.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "1.0.0"
"version": "independent"
}
2 changes: 1 addition & 1 deletion __fixtures__/toposort/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "independent"
"name": "toposort"
}
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ Array [
]
`;

exports[`VersionCommand versions all transitive dependents after change 1`] = `
exports[`VersionCommand version ordering versions all transitive dependents after change 1`] = `
"v2.0.0
HEAD -> master, tag: v2.0.0
Expand Down
48 changes: 38 additions & 10 deletions commands/version/__tests__/version-command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,20 +626,48 @@ describe("VersionCommand", () => {
expect(logMessages).toContain("No changed packages to version");
});

it("versions all transitive dependents after change", async () => {
const testDir = await initFixture("snake-graph");
describe("version ordering", () => {
it("versions all transitive dependents after change", async () => {
const testDir = await initFixture("snake-graph");

await gitTag(testDir, "v1.0.0");
await fs.outputFile(path.join(testDir, "packages/package-1/hello.js"), "world");
await gitAdd(testDir, ".");
await gitCommit(testDir, "feat: hello");
await gitTag(testDir, "v1.0.0");
await fs.outputFile(path.join(testDir, "packages/package-1/hello.js"), "world");
await gitAdd(testDir, ".");
await gitCommit(testDir, "feat: hello");

collectUpdates.mockImplementationOnce(collectUpdatesActual);

await lernaVersion(testDir)("major", "--yes");

const patch = await showCommit(testDir);
expect(patch).toMatchSnapshot();
});

collectUpdates.mockImplementationOnce(collectUpdatesActual);
it("handles cycles in topological order", async () => {
const testDir = await initFixture("cycle-parent");

await lernaVersion(testDir)("major", "--yes");
await gitTag(testDir, "v1.0.0");

const patch = await showCommit(testDir);
expect(patch).toMatchSnapshot();
await Promise.all(
["a", "b", "c", "d"].map(n => fs.outputFile(path.join(testDir, "packages", n, "index.js"), "hello"))
);
await gitAdd(testDir, ".");
await gitCommit(testDir, "feat: hello");

collectUpdates.mockImplementationOnce(collectUpdatesActual);

await lernaVersion(testDir)("major", "--yes");

const patch = await showCommit(testDir, "--name-only");
expect(patch).toMatchInlineSnapshot(`
"v2.0.0
HEAD -> master, tag: v2.0.0
lerna.json
packages/b/package.json"
`);
});
});

describe("with relative file: specifiers", () => {
Expand Down

0 comments on commit e5917a0

Please sign in to comment.