forked from dbrockman/jest-buffer-snapshot-serializer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
97 lines (88 loc) · 3.58 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const crypto = require("crypto");
const bytes = n => crypto.pbkdf2Sync("", "", 1, n, "sha256");
test("snapshot of a Buffer with 0 bytes", () => {
const buf = bytes(0);
const hex = buf.toString("hex");
expect(buf).toMatchInlineSnapshot(`Buffer<>`);
expect(hex).toMatchInlineSnapshot(`""`);
});
test("snapshot of a Buffer with 1 byte", () => {
const buf = bytes(1);
const hex = buf.toString("hex");
expect(buf).toMatchInlineSnapshot(`Buffer<f7>`);
expect(hex).toMatchInlineSnapshot(`"f7"`);
});
test("snapshot of a Buffer with 10 bytes", () => {
const buf = bytes(10);
const hex = buf.toString("hex");
expect(buf).toMatchInlineSnapshot(`Buffer<f7 ce 0b 65 3d 2d 72 a4 10 8c>`);
expect(hex).toMatchInlineSnapshot(`"f7ce0b653d2d72a4108c"`);
});
test("snapshot of a Buffer with 22 bytes", () => {
const buf = bytes(22);
const hex = buf.toString("hex");
expect(buf).toMatchInlineSnapshot(
`Buffer<f7 ce 0b 65 3d 2d 72 a4 10 8c f5 ab e9 12 ff dd 77 76 16 db bb 27>`
);
expect(hex).toMatchInlineSnapshot(
`"f7ce0b653d2d72a4108cf5abe912ffdd777616dbbb27"`
);
});
test("snapshot of a Buffer with 23 bytes", () => {
const buf = bytes(23);
const hex = buf.toString("hex");
expect(buf).toMatchInlineSnapshot(`
Buffer<
f7 ce 0b 65 3d 2d 72 a4 10 8c f5 ab e9 12 ff dd 77 76 16 db bb 27 a7
>
`);
expect(hex).toMatchInlineSnapshot(
`"f7ce0b653d2d72a4108cf5abe912ffdd777616dbbb27a7"`
);
});
test("snapshot of a Buffer with 26 bytes", () => {
const buf = bytes(26);
const hex = buf.toString("hex");
expect(buf).toMatchInlineSnapshot(`
Buffer<
f7 ce 0b 65 3d 2d 72 a4 10 8c f5 ab e9 12 ff dd 77 76 16 db bb 27 a7 0e 82 04
>
`);
expect(hex).toMatchInlineSnapshot(
`"f7ce0b653d2d72a4108cf5abe912ffdd777616dbbb27a70e8204"`
);
});
test("snapshot of a Buffer with 27 bytes", () => {
const buf = bytes(27);
const hex = buf.toString("hex");
expect(buf).toMatchInlineSnapshot(`
Buffer<
f7 ce 0b 65 3d 2d 72 a4 10 8c f5 ab e9 12 ff dd 77 76 16 db bb 27 a7 0e 82 04
f3
>
`);
expect(hex).toMatchInlineSnapshot(
`"f7ce0b653d2d72a4108cf5abe912ffdd777616dbbb27a70e8204f3"`
);
});
test("snapshot of a Buffer with 256 bytes", () => {
const buf = bytes(256);
const hex = buf.toString("hex");
expect(buf).toMatchInlineSnapshot(`
Buffer<
f7 ce 0b 65 3d 2d 72 a4 10 8c f5 ab e9 12 ff dd 77 76 16 db bb 27 a7 0e 82 04
f3 ae 2d 0f 6f ad 89 f6 8f 48 11 d1 e8 7b cc 3b d7 40 0a 9f fd 29 09 4f 01 84
63 95 74 f3 9a e5 a1 31 52 17 bc d7 89 49 91 44 72 13 bb 22 6c 25 b5 4d a8 63
70 fb cd 98 43 80 37 46 66 bb 8f fc b5 bf 40 c2 54 b0 67 d2 7c 51 ce 4a d5 fe
d8 29 c9 0b 50 5a 57 1b 7f 4d 1c ad 6a 52 3c da 77 0e 67 bc ea af 7e 89 ca ec
28 44 4f 46 49 d8 10 d9 bf ff a9 1a 53 0a 3d d6 d2 ab 15 2f 16 15 6b bf ca 07
73 e4 7c 0e a9 9e 54 15 0d e2 74 25 2a 20 ed 4d f3 dd 7a b0 ad 48 95 73 ab a1
7c a0 78 d6 74 5b c1 36 5d ec 72 7d ac 00 ae a5 f6 9d 7f c3 d7 5e 25 55 2e 5b
78 7b 6e bd 39 ea 6a 6f e6 ca ef 00 b8 98 c3 e8 91 7a 3c c1 21 3d 30 03 3c 3c
94 8e d3 84 03 e8 99 67 bf ce a5 35 47 d7 9a 3f 35 75 b3 fd bd d0
>
`);
expect(hex).toMatchInlineSnapshot(
`"f7ce0b653d2d72a4108cf5abe912ffdd777616dbbb27a70e8204f3ae2d0f6fad89f68f4811d1e87bcc3bd7400a9ffd29094f0184639574f39ae5a1315217bcd7894991447213bb226c25b54da86370fbcd984380374666bb8ffcb5bf40c254b067d27c51ce4ad5fed829c90b505a571b7f4d1cad6a523cda770e67bceaaf7e89caec28444f4649d810d9bfffa91a530a3dd6d2ab152f16156bbfca0773e47c0ea99e54150de274252a20ed4df3dd7ab0ad489573aba17ca078d6745bc1365dec727dac00aea5f69d7fc3d75e25552e5b787b6ebd39ea6a6fe6caef00b898c3e8917a3cc1213d30033c3c948ed38403e89967bfcea53547d79a3f3575b3fdbdd0"`
);
});