-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.js
49 lines (39 loc) · 1.09 KB
/
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
const {
encode,
decode,
convertUuidToUuid58,
convertUuid58ToUuid,
to58,
toU,
} = require('./index')
const xuuid = '7a2957d2-b79c-48c6-9771-270aed712fd8'
const xuuid58 = 'G5w1tJ2db6LJg8PxiEvkdm'
describe('uuid58', () => {
it('should convert a uuid to uuid58', () => {
expect(encode(xuuid)).toBe(xuuid58)
})
it('should convert an uppercase uuid to uuid58', () => {
expect(encode(xuuid.toUpperCase())).toBe(xuuid58)
})
it('should ignore already encoded', () => {
expect(encode(xuuid58)).toBe(xuuid58)
})
it('should convert a uuid58 to uuid', () => {
expect(decode(xuuid58)).toBe(xuuid)
})
it('should ignore already decoded', () => {
expect(decode(xuuid)).toBe(xuuid)
})
it('should have alias convertUuidToUuid58', () => {
expect(convertUuidToUuid58).toBe(encode)
})
it('should have alias convertUuidToUuid58', () => {
expect(convertUuid58ToUuid).toBe(decode)
})
it('should have alias convertUuidToUuid58', () => {
expect(to58).toBe(encode)
})
it('should have alias convertUuidToUuid58', () => {
expect(toU).toBe(decode)
})
})