forked from heygen-com/hyperframes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli-options.test.ts
More file actions
24 lines (21 loc) · 850 Bytes
/
Copy pathcli-options.test.ts
File metadata and controls
24 lines (21 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { CLI_SEMVER_PATTERN, validateCliVersion } from "./cli-options.ts";
function fail(message: string): never {
throw new Error(message);
}
describe("CLI semver validation", () => {
it("accepts stable and hyphenated prerelease versions", () => {
assert.doesNotThrow(() => validateCliVersion("1.2.3", CLI_SEMVER_PATTERN, fail));
assert.doesNotThrow(() => validateCliVersion("1.2.3-alpha.1", CLI_SEMVER_PATTERN, fail));
assert.doesNotThrow(() =>
validateCliVersion("1.2.3-alpha-feature.2", CLI_SEMVER_PATTERN, fail),
);
});
it("rejects underscores in prerelease versions", () => {
assert.throws(
() => validateCliVersion("1.2.3-alpha_1", CLI_SEMVER_PATTERN, fail),
/Invalid semver: 1\.2\.3-alpha_1/,
);
});
});