Skip to content

Commit 67b5160

Browse files
Address CodeRabbit review comments
- Add assertions to verify createPythonCode is called correctly in code cell tests - Add assertions to verify createMarkdown is called correctly in markdown cell tests - Add assertions to verify convertDeepnoteBlockToJupyterCell is called for all notebooks in transform tests - Verify mock call counts and arguments to strengthen test contracts
1 parent 0105761 commit 67b5160

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/__tests__/convert-deepnote-block-to-jupyter-cell.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ describe('convertDeepnoteBlockToJupyterCell', () => {
5151
expect(result.source).toBe('print("hello")');
5252
expect(result.execution_count).toBeNull();
5353
expect(result.outputs).toEqual([]);
54+
55+
const { createPythonCode } = jest.requireMock('@deepnote/blocks');
56+
expect(createPythonCode).toHaveBeenCalledTimes(1);
57+
expect(createPythonCode).toHaveBeenCalledWith(
58+
expect.objectContaining({ id: 'block-1' })
59+
);
5460
});
5561

5662
it('should include execution count if present', () => {
@@ -194,6 +200,12 @@ describe('convertDeepnoteBlockToJupyterCell', () => {
194200
expect(result.cell_type).toBe('markdown');
195201
expect(result.metadata).toEqual({});
196202
expect(result.source).toBe('# Hello');
203+
204+
const { createMarkdown } = jest.requireMock('@deepnote/blocks');
205+
expect(createMarkdown).toHaveBeenCalledTimes(1);
206+
expect(createMarkdown).toHaveBeenCalledWith(
207+
expect.objectContaining({ id: 'block-7' })
208+
);
197209
});
198210

199211
it('should convert text-cell-h1 to markdown cell', () => {

src/__tests__/transform-deepnote-yaml-to-notebook-content.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,24 @@ describe('transformDeepnoteYamlToNotebookContent', () => {
151151
expect(result.cells).toHaveLength(1);
152152
const cells = result.cells as any[];
153153
expect(cells[0].source).toBe('first_notebook_code');
154+
155+
const { convertDeepnoteBlockToJupyterCell } = jest.requireMock(
156+
'../convert-deepnote-block-to-jupyter-cell'
157+
);
158+
expect(convertDeepnoteBlockToJupyterCell).toHaveBeenCalledTimes(3);
159+
const calls = convertDeepnoteBlockToJupyterCell.mock.calls;
160+
expect(calls[0][0]).toMatchObject({
161+
id: 'block-1',
162+
source: 'first_notebook_code'
163+
});
164+
expect(calls[1][0]).toMatchObject({
165+
id: 'block-2',
166+
source: 'second_notebook_code'
167+
});
168+
expect(calls[2][0]).toMatchObject({
169+
id: 'block-1',
170+
source: 'first_notebook_code'
171+
});
154172
});
155173

156174
it('should handle empty notebooks gracefully', async () => {

0 commit comments

Comments
 (0)