-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: added tests for getConfigMultiSemrel.js
- Loading branch information
1 parent
08f01db
commit b12238a
Showing
15 changed files
with
282 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "msr-test-yarn", | ||
"author": "Dave Houlbrooke <[email protected]", | ||
"version": "0.0.0-semantically-released", | ||
"private": true, | ||
"license": "0BSD", | ||
"engines": { | ||
"node": ">=8.3" | ||
}, | ||
"workspaces": { | ||
"packages": ["packages/*"] | ||
}, | ||
"release": { | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator" | ||
], | ||
"noCi": true | ||
}, | ||
"multi-release": { | ||
"debug": true, | ||
"ignorePackages": ["!packages/d/**"], | ||
"deps": { | ||
"bump": "inherit" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "msr-test-a", | ||
"version": "0.0.0", | ||
"peerDependencies": { | ||
"msr-test-c": "*", | ||
"left-pad": "latest" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
test/fixtures/yarnWorkspacesConfig/packages/b/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "msr-test-b", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"msr-test-a": "*" | ||
}, | ||
"devDependencies": { | ||
"msr-test-c": "*", | ||
"left-pad": "latest" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
test/fixtures/yarnWorkspacesConfig/packages/c/.releaserc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"tagFormat": "multi-semantic-release-test-c@v${version}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "msr-test-c", | ||
"version": "0.0.0", | ||
"devDependencies": { | ||
"msr-test-b": "*", | ||
"msr-test-d": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "msr-test-d", | ||
"version": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
deps: { | ||
bump: "satisfy", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "msr-test-yarn", | ||
"author": "Dave Houlbrooke <[email protected]", | ||
"version": "0.0.0-semantically-released", | ||
"private": true, | ||
"license": "0BSD", | ||
"engines": { | ||
"node": ">=8.3" | ||
}, | ||
"workspaces": { | ||
"packages": ["packages/*"] | ||
}, | ||
"release": { | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator" | ||
], | ||
"noCi": true | ||
}, | ||
"multi-release": { | ||
"debug": true, | ||
"ignorePackages": ["!packages/d/**"], | ||
"deps": { | ||
"bump": "inherit" | ||
}, | ||
"extends": ["./config.js"] | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test/fixtures/yarnWorkspacesConfigExtends/packages/a/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "msr-test-a", | ||
"version": "0.0.0", | ||
"peerDependencies": { | ||
"msr-test-c": "*", | ||
"left-pad": "latest" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
test/fixtures/yarnWorkspacesConfigExtends/packages/b/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "msr-test-b", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"msr-test-a": "*" | ||
}, | ||
"devDependencies": { | ||
"msr-test-c": "*", | ||
"left-pad": "latest" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
test/fixtures/yarnWorkspacesConfigExtends/packages/c/.releaserc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"tagFormat": "multi-semantic-release-test-c@v${version}" | ||
} |
8 changes: 8 additions & 0 deletions
8
test/fixtures/yarnWorkspacesConfigExtends/packages/c/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "msr-test-c", | ||
"version": "0.0.0", | ||
"devDependencies": { | ||
"msr-test-b": "*", | ||
"msr-test-d": "*" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
test/fixtures/yarnWorkspacesConfigExtends/packages/d/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "msr-test-d", | ||
"version": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import getConfig from "../../lib/getConfigMultiSemrel.js"; | ||
import { gitInit } from "../helpers/git.js"; | ||
import { copyDirectory } from "../helpers/file.js"; | ||
|
||
// Tests. | ||
describe("getConfig()", () => { | ||
test("Default options", async () => { | ||
const result = await getConfig(process.cwd(), {}); | ||
expect(result).toMatchObject({ | ||
sequentialInit: false, | ||
sequentialPrepare: true, | ||
firstParent: false, | ||
debug: false, | ||
ignorePrivate: true, | ||
ignorePackages: [], | ||
tagFormat: "${name}@${version}", | ||
dryRun: false, | ||
deps: { | ||
bump: "override", | ||
release: "patch", | ||
prefix: "", | ||
}, | ||
}); | ||
}); | ||
|
||
test("Only CLI flags and default options", async () => { | ||
const cliFlags = { | ||
debug: true, | ||
ignorePackages: ["!packages/d/**"], | ||
deps: { | ||
bump: "inherit", | ||
}, | ||
}; | ||
const result = await getConfig(process.cwd(), cliFlags); | ||
expect(result).toMatchObject({ | ||
sequentialInit: false, | ||
sequentialPrepare: true, | ||
firstParent: false, | ||
debug: true, | ||
ignorePrivate: true, | ||
ignorePackages: ["!packages/d/**"], | ||
tagFormat: "${name}@${version}", | ||
dryRun: false, | ||
deps: { | ||
bump: "inherit", | ||
release: "patch", | ||
prefix: "", | ||
}, | ||
}); | ||
}); | ||
|
||
test("package.json config", async () => { | ||
const cwd = await gitInit(); | ||
copyDirectory(`test/fixtures/yarnWorkspacesConfig/`, cwd); | ||
const result = await getConfig(cwd, {}); | ||
expect(result).toMatchObject({ | ||
sequentialInit: false, | ||
sequentialPrepare: true, | ||
firstParent: false, | ||
debug: true, | ||
ignorePrivate: true, | ||
ignorePackages: ["!packages/d/**"], | ||
tagFormat: "${name}@${version}", | ||
dryRun: false, | ||
deps: { | ||
bump: "inherit", | ||
release: "patch", | ||
prefix: "", | ||
}, | ||
}); | ||
}); | ||
|
||
test("package.json config and CLI flags", async () => { | ||
const cwd = await gitInit(); | ||
const cliFlags = { | ||
debug: false, | ||
ignorePackages: ["!packages/c/**"], | ||
deps: { | ||
release: "minor", | ||
}, | ||
}; | ||
copyDirectory(`test/fixtures/yarnWorkspacesConfig/`, cwd); | ||
const result = await getConfig(cwd, cliFlags); | ||
expect(result).toMatchObject({ | ||
sequentialInit: false, | ||
sequentialPrepare: true, | ||
firstParent: false, | ||
debug: false, | ||
ignorePrivate: true, | ||
ignorePackages: ["!packages/d/**", "!packages/c/**"], | ||
tagFormat: "${name}@${version}", | ||
dryRun: false, | ||
deps: { | ||
bump: "inherit", | ||
release: "minor", | ||
prefix: "", | ||
}, | ||
}); | ||
}); | ||
|
||
test("package.json extends", async () => { | ||
const cwd = await gitInit(); | ||
copyDirectory(`test/fixtures/yarnWorkspacesConfigExtends/`, cwd); | ||
const result = await getConfig(cwd, {}); | ||
expect(result).toMatchObject({ | ||
sequentialInit: false, | ||
sequentialPrepare: true, | ||
firstParent: false, | ||
debug: true, | ||
ignorePrivate: true, | ||
ignorePackages: ["!packages/d/**"], | ||
tagFormat: "${name}@${version}", | ||
dryRun: false, | ||
deps: { | ||
bump: "satisfy", | ||
release: "patch", | ||
prefix: "", | ||
}, | ||
}); | ||
}); | ||
|
||
test("package.json extends and CLI flags", async () => { | ||
const cwd = await gitInit(); | ||
const cliFlags = { | ||
debug: false, | ||
ignorePackages: ["!packages/c/**"], | ||
deps: { | ||
release: "minor", | ||
}, | ||
}; | ||
copyDirectory(`test/fixtures/yarnWorkspacesConfigExtends/`, cwd); | ||
const result = await getConfig(cwd, cliFlags); | ||
expect(result).toMatchObject({ | ||
sequentialInit: false, | ||
sequentialPrepare: true, | ||
firstParent: false, | ||
debug: false, | ||
ignorePrivate: true, | ||
ignorePackages: ["!packages/d/**", "!packages/c/**"], | ||
tagFormat: "${name}@${version}", | ||
dryRun: false, | ||
deps: { | ||
bump: "satisfy", | ||
release: "minor", | ||
prefix: "", | ||
}, | ||
}); | ||
}); | ||
}); |