Skip to content

Commit 9b3303b

Browse files
committed
add tests for --deferred and --apply failures
1 parent 1cd27de commit 9b3303b

File tree

2 files changed

+62
-3
lines changed

2 files changed

+62
-3
lines changed

scripts/release/__tests__/version.test.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,68 @@ describe('Version', () => {
132132
`);
133133
});
134134

135+
it('should throw when apply is combined with releaseType', async () => {
136+
fsExtra.__setMockFiles({
137+
[CODE_PACKAGE_JSON_PATH]: JSON.stringify({ version: '1.0.0' }),
138+
[MANAGER_API_VERSION_PATH]: `export const version = "1.0.0";`,
139+
[VERSIONS_PATH]: `export default { "@storybook/addon-a11y": "1.0.0" };`,
140+
});
141+
142+
await expect(version({ apply: true, releaseType: 'prerelease' })).rejects
143+
.toThrowErrorMatchingInlineSnapshot(`
144+
"[
145+
{
146+
"code": "custom",
147+
"message": "--apply cannot be combined with --exact or --release-type, as it will always read from code/package.json#deferredNextVersion",
148+
"path": []
149+
}
150+
]"
151+
`);
152+
});
153+
154+
it('should throw when apply is combined with exact', async () => {
155+
fsExtra.__setMockFiles({
156+
[CODE_PACKAGE_JSON_PATH]: JSON.stringify({ version: '1.0.0' }),
157+
[MANAGER_API_VERSION_PATH]: `export const version = "1.0.0";`,
158+
[VERSIONS_PATH]: `export default { "@storybook/addon-a11y": "1.0.0" };`,
159+
});
160+
161+
await expect(version({ apply: true, exact: '1.0.0' })).rejects
162+
.toThrowErrorMatchingInlineSnapshot(`
163+
"[
164+
{
165+
"code": "custom",
166+
"message": "--apply cannot be combined with --exact or --release-type, as it will always read from code/package.json#deferredNextVersion",
167+
"path": []
168+
}
169+
]"
170+
`);
171+
});
172+
173+
it('should throw when apply is combined with deferred', async () => {
174+
fsExtra.__setMockFiles({
175+
[CODE_PACKAGE_JSON_PATH]: JSON.stringify({ version: '1.0.0' }),
176+
[MANAGER_API_VERSION_PATH]: `export const version = "1.0.0";`,
177+
[VERSIONS_PATH]: `export default { "@storybook/addon-a11y": "1.0.0" };`,
178+
});
179+
180+
await expect(version({ apply: true, deferred: true })).rejects
181+
.toThrowErrorMatchingInlineSnapshot(`
182+
"[
183+
{
184+
"code": "custom",
185+
"message": "--deferred cannot be combined with --apply",
186+
"path": []
187+
},
188+
{
189+
"code": "custom",
190+
"message": "Combining --exact with --release-type is invalid, but having one of them is required",
191+
"path": []
192+
}
193+
]"
194+
`);
195+
});
196+
135197
it.each([
136198
// prettier-ignore
137199
{ releaseType: 'major', currentVersion: '1.1.1', expectedVersion: '2.0.0' },

scripts/release/version.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ program
2929
.option('-A, --apply', 'Apply a deferred version bump')
3030
.option('-V, --verbose', 'Enable verbose logging', false);
3131

32-
/**
33-
* @see tocbot docs {@link https://tscanlin.github.io/tocbot/#usage}
34-
*/
3532
const optionsSchema = z
3633
.object({
3734
releaseType: z

0 commit comments

Comments
 (0)