Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion javascript/src/ycell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const createCell = (
}
if (cell.source != null) {
ycell.setSource(
typeof cell.source === 'string' ? cell.source : cell.source.join('\n')
typeof cell.source === 'string' ? cell.source : cell.source.join('')
);
}
return ycell;
Expand Down
13 changes: 12 additions & 1 deletion javascript/test/ycell.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { IMapChange, YCodeCell, YNotebook } from '../src';
import { createStandaloneCell, IMapChange, YCodeCell, YNotebook } from '../src';

describe('@jupyter/ydoc', () => {
// Fix awareness timeout open handle
Expand All @@ -13,6 +13,17 @@ describe('@jupyter/ydoc', () => {
jest.clearAllTimers();
});

describe('createStandaloneCell', () => {
test('should convert a source set as a list of string to a single string', () => {
const cell = createStandaloneCell({
cell_type: 'code',
source: ['import this\n', 'import math']
});

expect(cell.source).toEqual('import this\nimport math');
});
});

describe('YCell standalone', () => {
test('should set source', () => {
const codeCell = YCodeCell.create();
Expand Down