-
Notifications
You must be signed in to change notification settings - Fork 0
/
bytes2uuid_test.js
59 lines (46 loc) · 1.57 KB
/
bytes2uuid_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const bytes2uuid = require("./bytes2uuid")
describe("node", () => {
describe("bytes2uuid.js", () => {
describe("uuid_from_dv", () => {
test("zero", () => Promise.resolve(new ArrayBuffer(16))
.then(ab => new DataView(ab))
.then(dv => bytes2uuid.from_dv(dv))
.then(uuid => expect(uuid).toStrictEqual([0,0,0,0]))
)
})
describe("stringify", () => {
test("epoch", () => Promise.resolve(0x19700101)
.then(e => [e,e,e,e])
.then(bytes2uuid.stringify)
.then(s => expect(s).toBe("19700101197001011970010119700101"))
)
})
describe("beautify", () => {
test("epoch", () => Promise.resolve(0x19700101)
.then(e => [e,e,e,e])
.then(bytes2uuid.beautify)
.then(s => expect(s).toBe("19700101-1970-0101-1970-010119700101"))
)
test("f1", () => Promise.resolve(0x19700101)
.then(e => [0xf1234567,e,e,e])
.then(bytes2uuid.beautify)
.then(s => expect(s).toBe("f1234567-1970-0101-1970-010119700101"))
)
test("f2", () => Promise.resolve(0x19700101)
.then(e => [e,0xf1234567,e,e])
.then(bytes2uuid.beautify)
.then(s => expect(s).toBe("19700101-f123-4567-1970-010119700101"))
)
test("f3", () => Promise.resolve(0x19700101)
.then(e => [e,e,0xf1234567,e])
.then(bytes2uuid.beautify)
.then(s => expect(s).toBe("19700101-1970-0101-f123-456719700101"))
)
test("f4", () => Promise.resolve(0x19700101)
.then(e => [e,e,e,0xf1234567])
.then(bytes2uuid.beautify)
.then(s => expect(s).toBe("19700101-1970-0101-1970-0101f1234567"))
)
})
})
})