mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 02:02:35 -05:00
Save multiline source in notebooks (#6445)
* Save multiline source in notebooks * Stop demultiline localContentManager unnecessarily
This commit is contained in:
@@ -130,6 +130,121 @@ suite('Cell Model', function (): void {
|
||||
should(cell.language).equal('python');
|
||||
});
|
||||
|
||||
test('Should allow source of type string[] with length 1', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: ['print(1)'],
|
||||
metadata: { language: 'sql' },
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(Array.isArray(cell.source)).equal(true);
|
||||
should(cell.source.length).equal(1);
|
||||
should(cell.source[0]).equal('print(1)');
|
||||
});
|
||||
|
||||
test('Should allow source of type string', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(1)',
|
||||
metadata: { language: 'sql' },
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(Array.isArray(cell.source)).equal(false);
|
||||
should(cell.source).equal('print(1)');
|
||||
});
|
||||
|
||||
test('Should allow source of type string with newline and split it', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(1)\nprint(2)',
|
||||
metadata: { language: 'sql' },
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(Array.isArray(cell.source)).equal(true);
|
||||
should(cell.source.length).equal(2);
|
||||
should(cell.source[0]).equal('print(1)\n');
|
||||
should(cell.source[1]).equal('print(2)');
|
||||
});
|
||||
|
||||
test('Should allow source of type string with Windows style newline and split it', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(1)\r\nprint(2)',
|
||||
metadata: { language: 'sql' },
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(Array.isArray(cell.source)).equal(true);
|
||||
should(cell.source.length).equal(2);
|
||||
should(cell.source[0]).equal('print(1)\r\n');
|
||||
should(cell.source[1]).equal('print(2)');
|
||||
});
|
||||
|
||||
test('Should allow source of type string[] with length 2', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: ['print(1)\n', 'print(2)'],
|
||||
metadata: { language: 'sql' },
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(Array.isArray(cell.source)).equal(true);
|
||||
should(cell.source.length).equal(2);
|
||||
should(cell.source[0]).equal('print(1)\n');
|
||||
should(cell.source[1]).equal('print(2)');
|
||||
});
|
||||
|
||||
test('Should allow empty string source', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: '',
|
||||
metadata: { language: 'sql' },
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(Array.isArray(cell.source)).equal(false);
|
||||
should(cell.source).equal('');
|
||||
});
|
||||
|
||||
suite('Model Future handling', function (): void {
|
||||
let future: TypeMoq.Mock<EmptyFuture>;
|
||||
let cell: ICellModel;
|
||||
|
||||
Reference in New Issue
Block a user