@rozenite/storage-plugin 1.8.1 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +23 -0
- package/dist/devtools/assets/panel-Bm-SWF7d.js +33 -0
- package/dist/devtools/assets/panel-DIqI4WSp.css +1 -0
- package/dist/devtools/panel.html +2 -2
- package/dist/react-native/chunks/index.require.cjs +1 -1
- package/dist/react-native/chunks/index.require.js +43 -57
- package/dist/react-native/chunks/useRozeniteStoragePlugin.require.cjs +1 -1
- package/dist/react-native/chunks/useRozeniteStoragePlugin.require.js +253 -191
- package/dist/react-native/index.d.ts +29 -6
- package/dist/rozenite.json +1 -1
- package/dist/sdk/index.d.ts +1 -0
- package/package.json +9 -6
- package/src/react-native/__tests__/import.test.ts +182 -0
- package/src/react-native/adapters/__tests__/mmkv.test.ts +436 -0
- package/src/react-native/adapters/mmkv.ts +65 -39
- package/src/react-native/import.ts +67 -0
- package/src/react-native/storage-view.ts +16 -8
- package/src/react-native/useRozeniteStoragePlugin.ts +61 -36
- package/src/shared/__tests__/snapshot.test.ts +361 -0
- package/src/shared/messaging.ts +25 -1
- package/src/shared/snapshot.ts +276 -0
- package/src/shared/types.ts +1 -0
- package/src/ui/__tests__/binary-value-editor-state.test.ts +199 -0
- package/src/ui/__tests__/binary.test.ts +251 -0
- package/src/ui/__tests__/type-conversion.test.ts +123 -0
- package/src/ui/add-entry-dialog.tsx +83 -173
- package/src/ui/binary-value-editor-state.ts +125 -0
- package/src/ui/binary-value-editor.tsx +168 -0
- package/src/ui/binary.ts +123 -0
- package/src/ui/edit-entry-dialog.tsx +64 -161
- package/src/ui/editable-table.tsx +12 -10
- package/src/ui/editor-switcher.tsx +62 -0
- package/src/ui/entry-detail-dialog.tsx +14 -6
- package/src/ui/import-dialog.tsx +261 -0
- package/src/ui/panel.tsx +257 -57
- package/src/ui/type-conversion.ts +105 -0
- package/src/ui/typed-value-editor.tsx +96 -0
- package/src/ui/utils.ts +30 -0
- package/dist/devtools/assets/panel-DMhXYHH4.css +0 -1
- package/dist/devtools/assets/panel-eGOuOVos.js +0 -22
- package/src/react-native/is-garbled.ts +0 -17
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
base64ToBytes,
|
|
4
|
+
bytesToAsciiPreview,
|
|
5
|
+
bytesToBase64,
|
|
6
|
+
bytesToGroupedHex,
|
|
7
|
+
bytesToHexdump,
|
|
8
|
+
compactBufferPreview,
|
|
9
|
+
hexInputToBytes,
|
|
10
|
+
} from '../binary';
|
|
11
|
+
|
|
12
|
+
// 0x89 'P' 'N' 'G' \r \n 0x1A \n - the canonical PNG signature.
|
|
13
|
+
const PNG_SIGNATURE = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
|
14
|
+
|
|
15
|
+
describe('bytesToGroupedHex', () => {
|
|
16
|
+
it('returns empty string for empty bytes', () => {
|
|
17
|
+
expect(bytesToGroupedHex([])).toBe('');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('groups under 8 bytes without a double-space separator', () => {
|
|
21
|
+
expect(bytesToGroupedHex([0x89, 0x50])).toBe('89 50');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('inserts a double-space gap between bytes 8 and 9', () => {
|
|
25
|
+
expect(
|
|
26
|
+
bytesToGroupedHex([
|
|
27
|
+
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
|
28
|
+
0x49, 0x48, 0x44, 0x52,
|
|
29
|
+
]),
|
|
30
|
+
).toBe('89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('wraps after 16 bytes with a newline', () => {
|
|
34
|
+
const bytes = new Array(20).fill(0xff);
|
|
35
|
+
const out = bytesToGroupedHex(bytes);
|
|
36
|
+
const lines = out.split('\n');
|
|
37
|
+
expect(lines).toHaveLength(2);
|
|
38
|
+
expect(lines[0]).toBe('FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF');
|
|
39
|
+
expect(lines[1]).toBe('FF FF FF FF');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('bytesToHexdump', () => {
|
|
44
|
+
it('renders offset, grouped hex, and ASCII column', () => {
|
|
45
|
+
const bytes = [
|
|
46
|
+
...PNG_SIGNATURE,
|
|
47
|
+
0x00,
|
|
48
|
+
0x00,
|
|
49
|
+
0x00,
|
|
50
|
+
0x0d,
|
|
51
|
+
0x49,
|
|
52
|
+
0x48,
|
|
53
|
+
0x44,
|
|
54
|
+
0x52,
|
|
55
|
+
];
|
|
56
|
+
expect(bytesToHexdump(bytes)).toBe(
|
|
57
|
+
'00000000 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 |.PNG........IHDR|',
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('uses lowercase 8-digit offsets that increment by 16', () => {
|
|
62
|
+
const bytes = new Array(20).fill(0x41);
|
|
63
|
+
const lines = bytesToHexdump(bytes).split('\n');
|
|
64
|
+
expect(lines[0].startsWith('00000000 ')).toBe(true);
|
|
65
|
+
expect(lines[1].startsWith('00000010 ')).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('pads the hex column on a partial trailing line so ASCII aligns', () => {
|
|
69
|
+
const bytes = [0x41, 0x42, 0x43];
|
|
70
|
+
const line = bytesToHexdump(bytes);
|
|
71
|
+
// Hex section width must be exactly 48 chars before the " |..." block.
|
|
72
|
+
expect(line).toBe(
|
|
73
|
+
'00000000 41 42 43 |ABC|',
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('renders non-printable bytes as dots in the ASCII column', () => {
|
|
78
|
+
const bytes = [0x00, 0x09, 0x1f, 0x20, 0x7e, 0x7f, 0xff];
|
|
79
|
+
expect(bytesToHexdump(bytes)).toContain('|... ~..|');
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('bytesToAsciiPreview', () => {
|
|
84
|
+
it('maps printable bytes to characters', () => {
|
|
85
|
+
expect(bytesToAsciiPreview([0x48, 0x69])).toBe('Hi');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('treats bytes outside 0x20..0x7E as "."', () => {
|
|
89
|
+
expect(bytesToAsciiPreview([0x1f, 0x20, 0x7e, 0x7f])).toBe('. ~.');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('treats tab and newline as non-printable', () => {
|
|
93
|
+
expect(bytesToAsciiPreview([0x09, 0x0a, 0x0d])).toBe('...');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('bytesToBase64 / base64ToBytes round-trip', () => {
|
|
98
|
+
it('encodes simple ASCII to base64 and back', () => {
|
|
99
|
+
const bytes = [0x48, 0x65, 0x6c, 0x6c, 0x6f]; // "Hello"
|
|
100
|
+
const encoded = bytesToBase64(bytes);
|
|
101
|
+
expect(encoded).toBe('SGVsbG8=');
|
|
102
|
+
const decoded = base64ToBytes(encoded);
|
|
103
|
+
expect(decoded).toEqual({ ok: true, value: bytes });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('round-trips arbitrary bytes including high values', () => {
|
|
107
|
+
const bytes = [0x00, 0xff, 0x89, 0x50, 0x4e, 0x47];
|
|
108
|
+
const decoded = base64ToBytes(bytesToBase64(bytes));
|
|
109
|
+
expect(decoded).toEqual({ ok: true, value: bytes });
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('accepts base64 with surrounding and internal whitespace', () => {
|
|
113
|
+
expect(base64ToBytes(' SGVs\nbG8= ')).toEqual({
|
|
114
|
+
ok: true,
|
|
115
|
+
value: [0x48, 0x65, 0x6c, 0x6c, 0x6f],
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('rejects empty input with the canonical message', () => {
|
|
120
|
+
expect(base64ToBytes('')).toEqual({
|
|
121
|
+
ok: false,
|
|
122
|
+
error: 'Enter at least one byte.',
|
|
123
|
+
});
|
|
124
|
+
expect(base64ToBytes(' ')).toEqual({
|
|
125
|
+
ok: false,
|
|
126
|
+
error: 'Enter at least one byte.',
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('rejects malformed base64', () => {
|
|
131
|
+
expect(base64ToBytes('not*valid*base64')).toEqual({
|
|
132
|
+
ok: false,
|
|
133
|
+
error: 'Base64 input is invalid.',
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('compactBufferPreview', () => {
|
|
139
|
+
it('renders just the size for an empty buffer', () => {
|
|
140
|
+
expect(compactBufferPreview([])).toBe('0 B');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('omits the ellipsis when the buffer fits within maxBytes', () => {
|
|
144
|
+
expect(compactBufferPreview([0x89, 0x50, 0x4e, 0x47])).toBe(
|
|
145
|
+
'89 50 4E 47 4 B',
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('includes an ellipsis when truncated', () => {
|
|
150
|
+
expect(compactBufferPreview(new Array(128).fill(0xab))).toBe(
|
|
151
|
+
'AB AB AB AB AB AB AB AB … 128 B',
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('respects a custom maxBytes', () => {
|
|
156
|
+
expect(compactBufferPreview([0x01, 0x02, 0x03], { maxBytes: 2 })).toBe(
|
|
157
|
+
'01 02 … 3 B',
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
describe('hexInputToBytes', () => {
|
|
163
|
+
it('parses continuous hex', () => {
|
|
164
|
+
expect(hexInputToBytes('deadbeef')).toEqual({
|
|
165
|
+
ok: true,
|
|
166
|
+
value: [0xde, 0xad, 0xbe, 0xef],
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('parses grouped hex', () => {
|
|
171
|
+
expect(hexInputToBytes('DE AD BE EF')).toEqual({
|
|
172
|
+
ok: true,
|
|
173
|
+
value: [0xde, 0xad, 0xbe, 0xef],
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('parses multiline grouped hex', () => {
|
|
178
|
+
expect(
|
|
179
|
+
hexInputToBytes(
|
|
180
|
+
'89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52\n00 00 00 20 00 00 00 20',
|
|
181
|
+
),
|
|
182
|
+
).toEqual({
|
|
183
|
+
ok: true,
|
|
184
|
+
value: [
|
|
185
|
+
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
|
186
|
+
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20,
|
|
187
|
+
],
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('parses pasted hexdump rows, stripping offsets and ASCII column', () => {
|
|
192
|
+
const pasted = [
|
|
193
|
+
'00000000 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 |.PNG........IHDR|',
|
|
194
|
+
'00000010 00 00 00 20 00 00 00 20 08 06 00 00 00 73 7A 7A |... ... .....szz|',
|
|
195
|
+
].join('\n');
|
|
196
|
+
expect(hexInputToBytes(pasted)).toEqual({
|
|
197
|
+
ok: true,
|
|
198
|
+
value: [
|
|
199
|
+
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
|
200
|
+
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20,
|
|
201
|
+
0x08, 0x06, 0x00, 0x00, 0x00, 0x73, 0x7a, 0x7a,
|
|
202
|
+
],
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('accepts colon-separated hexdump offsets', () => {
|
|
207
|
+
expect(hexInputToBytes('00000000: 89 50 4E 47')).toEqual({
|
|
208
|
+
ok: true,
|
|
209
|
+
value: [0x89, 0x50, 0x4e, 0x47],
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('strips "0x" prefixes', () => {
|
|
214
|
+
expect(hexInputToBytes('0xDE 0xAD 0xBE 0xEF')).toEqual({
|
|
215
|
+
ok: true,
|
|
216
|
+
value: [0xde, 0xad, 0xbe, 0xef],
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('tolerates mixed case', () => {
|
|
221
|
+
expect(hexInputToBytes('De Ad bE eF')).toEqual({
|
|
222
|
+
ok: true,
|
|
223
|
+
value: [0xde, 0xad, 0xbe, 0xef],
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('rejects empty input with the canonical message', () => {
|
|
228
|
+
expect(hexInputToBytes('')).toEqual({
|
|
229
|
+
ok: false,
|
|
230
|
+
error: 'Enter at least one byte.',
|
|
231
|
+
});
|
|
232
|
+
expect(hexInputToBytes(' \n ')).toEqual({
|
|
233
|
+
ok: false,
|
|
234
|
+
error: 'Enter at least one byte.',
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('rejects non-hex characters', () => {
|
|
239
|
+
expect(hexInputToBytes('DE AD GG')).toEqual({
|
|
240
|
+
ok: false,
|
|
241
|
+
error: 'Hex input contains invalid characters.',
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('rejects odd hex digit count', () => {
|
|
246
|
+
expect(hexInputToBytes('DEAD B')).toEqual({
|
|
247
|
+
ok: false,
|
|
248
|
+
error: 'Hex input must contain complete bytes.',
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { convertValue, defaultValueForType } from '../type-conversion';
|
|
3
|
+
|
|
4
|
+
describe('convertValue', () => {
|
|
5
|
+
it('returns the same value when from === to', () => {
|
|
6
|
+
expect(convertValue('string', 'string', 'hello')).toBe('hello');
|
|
7
|
+
expect(convertValue('number', 'number', 42)).toBe(42);
|
|
8
|
+
expect(convertValue('boolean', 'boolean', true)).toBe(true);
|
|
9
|
+
expect(convertValue('buffer', 'buffer', [1, 2, 3])).toEqual([1, 2, 3]);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe('from string', () => {
|
|
13
|
+
it('parses a numeric string to a number, falls back to 0 on NaN', () => {
|
|
14
|
+
expect(convertValue('string', 'number', '42')).toBe(42);
|
|
15
|
+
expect(convertValue('string', 'number', '-3.14')).toBe(-3.14);
|
|
16
|
+
expect(convertValue('string', 'number', 'abc')).toBe(0);
|
|
17
|
+
expect(convertValue('string', 'number', '')).toBe(0);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('parses "true" / anything-else to a boolean', () => {
|
|
21
|
+
expect(convertValue('string', 'boolean', 'true')).toBe(true);
|
|
22
|
+
expect(convertValue('string', 'boolean', 'false')).toBe(false);
|
|
23
|
+
expect(convertValue('string', 'boolean', 'anything')).toBe(false);
|
|
24
|
+
expect(convertValue('string', 'boolean', '')).toBe(false);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('UTF-8 encodes a string to a byte array', () => {
|
|
28
|
+
expect(convertValue('string', 'buffer', 'hello')).toEqual([
|
|
29
|
+
0x68, 0x65, 0x6c, 0x6c, 0x6f,
|
|
30
|
+
]);
|
|
31
|
+
// 'é' is two bytes in UTF-8: 0xC3 0xA9.
|
|
32
|
+
expect(convertValue('string', 'buffer', 'café')).toEqual([
|
|
33
|
+
0x63, 0x61, 0x66, 0xc3, 0xa9,
|
|
34
|
+
]);
|
|
35
|
+
expect(convertValue('string', 'buffer', '')).toEqual([]);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('from number', () => {
|
|
40
|
+
it('stringifies a number when converting to string', () => {
|
|
41
|
+
expect(convertValue('number', 'string', 42)).toBe('42');
|
|
42
|
+
expect(convertValue('number', 'string', -3.14)).toBe('-3.14');
|
|
43
|
+
expect(convertValue('number', 'string', 0)).toBe('0');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('non-zero is truthy, zero is falsy for boolean conversion', () => {
|
|
47
|
+
expect(convertValue('number', 'boolean', 1)).toBe(true);
|
|
48
|
+
expect(convertValue('number', 'boolean', -1)).toBe(true);
|
|
49
|
+
expect(convertValue('number', 'boolean', 0)).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('UTF-8 encodes the stringified number to buffer', () => {
|
|
53
|
+
expect(convertValue('number', 'buffer', 42)).toEqual([0x34, 0x32]);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('from boolean', () => {
|
|
58
|
+
it('stringifies to "true" / "false"', () => {
|
|
59
|
+
expect(convertValue('boolean', 'string', true)).toBe('true');
|
|
60
|
+
expect(convertValue('boolean', 'string', false)).toBe('false');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('true → 1, false → 0 for number conversion', () => {
|
|
64
|
+
expect(convertValue('boolean', 'number', true)).toBe(1);
|
|
65
|
+
expect(convertValue('boolean', 'number', false)).toBe(0);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('encodes the literal "true" / "false" bytes for buffer conversion', () => {
|
|
69
|
+
expect(convertValue('boolean', 'buffer', true)).toEqual([
|
|
70
|
+
0x74, 0x72, 0x75, 0x65,
|
|
71
|
+
]);
|
|
72
|
+
expect(convertValue('boolean', 'buffer', false)).toEqual([
|
|
73
|
+
0x66, 0x61, 0x6c, 0x73, 0x65,
|
|
74
|
+
]);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('from buffer', () => {
|
|
79
|
+
it('UTF-8 decodes bytes back to a string (the headline round-trip)', () => {
|
|
80
|
+
expect(
|
|
81
|
+
convertValue('buffer', 'string', [0x68, 0x65, 0x6c, 0x6c, 0x6f]),
|
|
82
|
+
).toBe('hello');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('returns an empty string when bytes are not valid UTF-8', () => {
|
|
86
|
+
expect(convertValue('buffer', 'string', [0xff, 0xfe, 0xfd])).toBe('');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('decodes then parses to number, falls back to 0 on failure', () => {
|
|
90
|
+
expect(convertValue('buffer', 'number', [0x34, 0x32])).toBe(42); // "42"
|
|
91
|
+
expect(
|
|
92
|
+
convertValue('buffer', 'number', [0x68, 0x65, 0x6c, 0x6c, 0x6f]),
|
|
93
|
+
).toBe(0); // "hello" → NaN → 0
|
|
94
|
+
expect(convertValue('buffer', 'number', [0xff])).toBe(0); // invalid UTF-8 → 0
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('decodes then matches "true" for boolean conversion', () => {
|
|
98
|
+
expect(convertValue('buffer', 'boolean', [0x74, 0x72, 0x75, 0x65])).toBe(
|
|
99
|
+
true,
|
|
100
|
+
);
|
|
101
|
+
expect(
|
|
102
|
+
convertValue('buffer', 'boolean', [0x66, 0x61, 0x6c, 0x73, 0x65]),
|
|
103
|
+
).toBe(false);
|
|
104
|
+
expect(convertValue('buffer', 'boolean', [0xff])).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('round-trips string ↔ buffer faithfully', () => {
|
|
109
|
+
const original = 'Hello, world! — 你好';
|
|
110
|
+
const bytes = convertValue('string', 'buffer', original) as number[];
|
|
111
|
+
const back = convertValue('buffer', 'string', bytes);
|
|
112
|
+
expect(back).toBe(original);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('defaultValueForType', () => {
|
|
117
|
+
it('returns sensible zero values', () => {
|
|
118
|
+
expect(defaultValueForType('string')).toBe('');
|
|
119
|
+
expect(defaultValueForType('number')).toBe(0);
|
|
120
|
+
expect(defaultValueForType('boolean')).toBe(false);
|
|
121
|
+
expect(defaultValueForType('buffer')).toEqual([]);
|
|
122
|
+
});
|
|
123
|
+
});
|