Skip to content

Commit 78d3cb7

Browse files
committed
Refactor ChartBigNumberBlockConverter tests to use deepStrictEqual for assertions
1 parent d220422 commit 78d3cb7

File tree

1 file changed

+84
-63
lines changed

1 file changed

+84
-63
lines changed

src/notebooks/deepnote/converters/chartBigNumberBlockConverter.unit.test.ts

Lines changed: 84 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@ suite('ChartBigNumberBlockConverter', () => {
5353
assert.strictEqual(cell.languageId, 'json');
5454

5555
const config = JSON.parse(cell.value);
56-
assert.strictEqual(config.deepnote_big_number_title, 'test title');
57-
assert.strictEqual(config.deepnote_big_number_value, 'b');
58-
assert.strictEqual(config.deepnote_big_number_format, 'number');
59-
assert.strictEqual(config.deepnote_big_number_comparison_type, 'percentage-change');
60-
assert.strictEqual(config.deepnote_big_number_comparison_title, 'vs a');
61-
assert.strictEqual(config.deepnote_big_number_comparison_value, 'a');
62-
assert.strictEqual(config.deepnote_big_number_comparison_format, '');
63-
assert.strictEqual(config.deepnote_big_number_comparison_enabled, true);
56+
assert.deepStrictEqual(config, {
57+
deepnote_big_number_title: 'test title',
58+
deepnote_big_number_value: 'b',
59+
deepnote_big_number_format: 'number',
60+
deepnote_big_number_comparison_type: 'percentage-change',
61+
deepnote_big_number_comparison_title: 'vs a',
62+
deepnote_big_number_comparison_value: 'a',
63+
deepnote_big_number_comparison_format: '',
64+
deepnote_big_number_comparison_enabled: true
65+
});
6466
});
6567

6668
test('converts absolute change comparison block to cell', () => {
@@ -104,14 +106,16 @@ suite('ChartBigNumberBlockConverter', () => {
104106
assert.strictEqual(cell.languageId, 'json');
105107

106108
const config = JSON.parse(cell.value);
107-
assert.strictEqual(config.deepnote_big_number_title, 'absolute change 2');
108-
assert.strictEqual(config.deepnote_big_number_value, 'b');
109-
assert.strictEqual(config.deepnote_big_number_format, 'number');
110-
assert.strictEqual(config.deepnote_big_number_comparison_type, 'absolute-change');
111-
assert.strictEqual(config.deepnote_big_number_comparison_title, 'vs a');
112-
assert.strictEqual(config.deepnote_big_number_comparison_value, 'a');
113-
assert.strictEqual(config.deepnote_big_number_comparison_format, '');
114-
assert.strictEqual(config.deepnote_big_number_comparison_enabled, true);
109+
assert.deepStrictEqual(config, {
110+
deepnote_big_number_title: 'absolute change 2',
111+
deepnote_big_number_value: 'b',
112+
deepnote_big_number_format: 'number',
113+
deepnote_big_number_comparison_type: 'absolute-change',
114+
deepnote_big_number_comparison_title: 'vs a',
115+
deepnote_big_number_comparison_value: 'a',
116+
deepnote_big_number_comparison_format: '',
117+
deepnote_big_number_comparison_enabled: true
118+
});
115119
});
116120

117121
test('converts absolute value comparison block to cell', () => {
@@ -155,14 +159,16 @@ suite('ChartBigNumberBlockConverter', () => {
155159
assert.strictEqual(cell.languageId, 'json');
156160

157161
const config = JSON.parse(cell.value);
158-
assert.strictEqual(config.deepnote_big_number_title, 'absolute change 2');
159-
assert.strictEqual(config.deepnote_big_number_value, 'b');
160-
assert.strictEqual(config.deepnote_big_number_format, 'number');
161-
assert.strictEqual(config.deepnote_big_number_comparison_type, 'absolute-value');
162-
assert.strictEqual(config.deepnote_big_number_comparison_title, 'vs a');
163-
assert.strictEqual(config.deepnote_big_number_comparison_value, 'a');
164-
assert.strictEqual(config.deepnote_big_number_comparison_format, '');
165-
assert.strictEqual(config.deepnote_big_number_comparison_enabled, true);
162+
assert.deepStrictEqual(config, {
163+
deepnote_big_number_title: 'absolute change 2',
164+
deepnote_big_number_value: 'b',
165+
deepnote_big_number_format: 'number',
166+
deepnote_big_number_comparison_type: 'absolute-value',
167+
deepnote_big_number_comparison_title: 'vs a',
168+
deepnote_big_number_comparison_value: 'a',
169+
deepnote_big_number_comparison_format: '',
170+
deepnote_big_number_comparison_enabled: true
171+
});
166172
});
167173

168174
test('converts disabled comparison block to cell', () => {
@@ -206,14 +212,16 @@ suite('ChartBigNumberBlockConverter', () => {
206212
assert.strictEqual(cell.languageId, 'json');
207213

208214
const config = JSON.parse(cell.value);
209-
assert.strictEqual(config.deepnote_big_number_title, 'some title');
210-
assert.strictEqual(config.deepnote_big_number_value, 'b');
211-
assert.strictEqual(config.deepnote_big_number_format, 'plain');
212-
assert.strictEqual(config.deepnote_big_number_comparison_type, 'percentage-change');
213-
assert.strictEqual(config.deepnote_big_number_comparison_title, 'vs a');
214-
assert.strictEqual(config.deepnote_big_number_comparison_value, 'a');
215-
assert.strictEqual(config.deepnote_big_number_comparison_format, '');
216-
assert.strictEqual(config.deepnote_big_number_comparison_enabled, false);
215+
assert.deepStrictEqual(config, {
216+
deepnote_big_number_title: 'some title',
217+
deepnote_big_number_value: 'b',
218+
deepnote_big_number_format: 'plain',
219+
deepnote_big_number_comparison_type: 'percentage-change',
220+
deepnote_big_number_comparison_title: 'vs a',
221+
deepnote_big_number_comparison_value: 'a',
222+
deepnote_big_number_comparison_format: '',
223+
deepnote_big_number_comparison_enabled: false
224+
});
217225
});
218226

219227
test('prefers raw content when DEEPNOTE_VSCODE_RAW_CONTENT_KEY exists', () => {
@@ -259,14 +267,16 @@ suite('ChartBigNumberBlockConverter', () => {
259267
assert.strictEqual(cell.languageId, 'json');
260268

261269
const config = JSON.parse(cell.value);
262-
assert.strictEqual(config.deepnote_big_number_title, null);
263-
assert.strictEqual(config.deepnote_big_number_value, null);
264-
assert.strictEqual(config.deepnote_big_number_format, null);
265-
assert.strictEqual(config.deepnote_big_number_comparison_type, null);
266-
assert.strictEqual(config.deepnote_big_number_comparison_title, null);
267-
assert.strictEqual(config.deepnote_big_number_comparison_value, null);
268-
assert.strictEqual(config.deepnote_big_number_comparison_format, null);
269-
assert.strictEqual(config.deepnote_big_number_comparison_enabled, null);
270+
assert.deepStrictEqual(config, {
271+
deepnote_big_number_title: null,
272+
deepnote_big_number_value: null,
273+
deepnote_big_number_format: null,
274+
deepnote_big_number_comparison_type: null,
275+
deepnote_big_number_comparison_title: null,
276+
deepnote_big_number_comparison_value: null,
277+
deepnote_big_number_comparison_format: null,
278+
deepnote_big_number_comparison_enabled: null
279+
});
270280
});
271281

272282
test('uses default config when metadata is empty', () => {
@@ -285,14 +295,16 @@ suite('ChartBigNumberBlockConverter', () => {
285295
assert.strictEqual(cell.languageId, 'json');
286296

287297
const config = JSON.parse(cell.value);
288-
assert.strictEqual(config.deepnote_big_number_title, null);
289-
assert.strictEqual(config.deepnote_big_number_value, null);
290-
assert.strictEqual(config.deepnote_big_number_format, null);
291-
assert.strictEqual(config.deepnote_big_number_comparison_type, null);
292-
assert.strictEqual(config.deepnote_big_number_comparison_title, null);
293-
assert.strictEqual(config.deepnote_big_number_comparison_value, null);
294-
assert.strictEqual(config.deepnote_big_number_comparison_format, null);
295-
assert.strictEqual(config.deepnote_big_number_comparison_enabled, null);
298+
assert.deepStrictEqual(config, {
299+
deepnote_big_number_title: null,
300+
deepnote_big_number_value: null,
301+
deepnote_big_number_format: null,
302+
deepnote_big_number_comparison_type: null,
303+
deepnote_big_number_comparison_title: null,
304+
deepnote_big_number_comparison_value: null,
305+
deepnote_big_number_comparison_format: null,
306+
deepnote_big_number_comparison_enabled: null
307+
});
296308
});
297309
});
298310

@@ -325,15 +337,17 @@ suite('ChartBigNumberBlockConverter', () => {
325337
converter.applyChangesToBlock(block, cell);
326338

327339
assert.strictEqual(block.content, '');
328-
assert.strictEqual(block.metadata?.deepnote_big_number_title, 'new title');
329-
assert.strictEqual(block.metadata?.deepnote_big_number_value, 'new value');
330-
assert.strictEqual(block.metadata?.deepnote_big_number_format, 'number');
331-
assert.strictEqual(block.metadata?.deepnote_big_number_comparison_type, 'percentage-change');
332-
assert.strictEqual(block.metadata?.deepnote_big_number_comparison_title, 'vs old');
333-
assert.strictEqual(block.metadata?.deepnote_big_number_comparison_value, 'old value');
334-
assert.strictEqual(block.metadata?.deepnote_big_number_comparison_format, '');
335-
assert.strictEqual(block.metadata?.deepnote_big_number_comparison_enabled, true);
336-
assert.strictEqual(block.metadata?.existing, 'value');
340+
assert.deepStrictEqual(block.metadata, {
341+
existing: 'value',
342+
deepnote_big_number_title: 'new title',
343+
deepnote_big_number_value: 'new value',
344+
deepnote_big_number_format: 'number',
345+
deepnote_big_number_comparison_type: 'percentage-change',
346+
deepnote_big_number_comparison_title: 'vs old',
347+
deepnote_big_number_comparison_value: 'old value',
348+
deepnote_big_number_comparison_format: '',
349+
deepnote_big_number_comparison_enabled: true
350+
});
337351
});
338352

339353
test('stores invalid JSON as raw content', () => {
@@ -423,12 +437,19 @@ suite('ChartBigNumberBlockConverter', () => {
423437

424438
converter.applyChangesToBlock(block, cell);
425439

426-
assert.strictEqual(block.id, 'block-123');
427-
assert.strictEqual(block.type, 'big-number');
428-
assert.strictEqual(block.sortingKey, 'a0');
429-
assert.strictEqual(block.executionCount, 5);
430-
assert.deepStrictEqual(block.outputs, []);
431-
assert.strictEqual(block.metadata?.custom, 'value');
440+
assert.deepStrictEqual(block, {
441+
blockGroup: 'test-group',
442+
content: '',
443+
executionCount: 5,
444+
id: 'block-123',
445+
metadata: {
446+
custom: 'value',
447+
deepnote_big_number_title: 'new title'
448+
},
449+
outputs: [],
450+
sortingKey: 'a0',
451+
type: 'big-number'
452+
});
432453
});
433454
});
434455
});

0 commit comments

Comments
 (0)