feat: support UUID v1, v3, v4, v5, v6, v7

- Add v6 and v7 as valid options
- Add unit tests for generating and analyzing all supported versions
This commit is contained in:
Bart van Andel 2025-04-03 14:08:14 +02:00
parent e0bdde89c4
commit 457d28fc55
2 changed files with 12 additions and 12 deletions

View file

@ -580,18 +580,18 @@ Password: 282760`;
assert.strictEqual(result.toString().substr(0, 37), "-----BEGIN PGP PRIVATE KEY BLOCK-----");
}),
it("Generate UUID v1", () => {
const result = chef.generateUUID("", { version: "v1" }).toString();
...[1, 3, 4, 5, 6, 7].map(version => it(`Generate UUID v${version}`, () => {
const result = chef.generateUUID("", { "UUID version": `v${version}` }).toString();
assert.ok(result);
assert.equal(result.length, 36);
}),
assert.strictEqual(result.length, 36);
})),
it("Analyse UUID v1", () => {
const uuidv1 = chef.generateUUID("", { version: "v1" }).toString();
const uuidAnalysis = chef.analyseUUID(uuidv1).toString();
assert.equal(uuidAnalysis, "UUID version: 1");
}),
...[1, 3, 4, 5, 6, 7].map(version => it(`Analyze UUID v${version}`, () => {
const uuid = chef.generateUUID("", { "UUID version": `v${version}` }).toString();
const result = chef.analyseUUID(uuid).toString();
const expected = `UUID version: ${version}`;
assert.strictEqual(result, expected);
})),
it("Gzip, Gunzip", () => {
assert.strictEqual(chef.gunzip(chef.gzip("Down To The Wire")).toString(), "Down To The Wire");