mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 09:35:37 -05:00
Replace deprecated assert functions in test files. (#16945)
This commit is contained in:
@@ -32,66 +32,66 @@ suite('Cell Magic Mapper', function (): void {
|
||||
test('Should find no magics when empty array passed into constructor', () => {
|
||||
cellMagicMapper = new CellMagicMapper([]);
|
||||
magic = cellMagicMapper.toLanguageMagic('', '');
|
||||
assert.equal(magic, undefined, 'cell magic should not exist when magic name and kernel is empty string');
|
||||
assert.strictEqual(magic, undefined, 'cell magic should not exist when magic name and kernel is empty string');
|
||||
|
||||
magic = cellMagicMapper.toLanguageMagic('magicName', 'kernel1');
|
||||
assert.equal(magic, undefined, 'cell magic should not exist when magic name and kernel strings are not empty');
|
||||
assert.strictEqual(magic, undefined, 'cell magic should not exist when magic name and kernel strings are not empty');
|
||||
|
||||
magic = cellMagicMapper.toLanguageMagic(undefined, undefined);
|
||||
assert.equal(magic, undefined, 'cell magic should not exist when magic name and kernel strings are undefined');
|
||||
assert.strictEqual(magic, undefined, 'cell magic should not exist when magic name and kernel strings are undefined');
|
||||
});
|
||||
|
||||
test('Should find magic when magic is passed into constructor', () => {
|
||||
cellMagicMapper = new CellMagicMapper([sampleLanguageMagicWithKernel]);
|
||||
magic = cellMagicMapper.toLanguageMagic('sampleMagic', 'kernel1');
|
||||
assert.deepEqual(magic, sampleLanguageMagicWithKernel, 'cell magic should match sample magic when looking for first kernel');
|
||||
assert.deepStrictEqual(magic, sampleLanguageMagicWithKernel, 'cell magic should match sample magic when looking for first kernel');
|
||||
|
||||
magic = cellMagicMapper.toLanguageMagic('sampleMagic', 'kernel2');
|
||||
assert.deepEqual(magic, sampleLanguageMagicWithKernel, 'cell magic should match sample magic when looking for second kernel');
|
||||
assert.deepStrictEqual(magic, sampleLanguageMagicWithKernel, 'cell magic should match sample magic when looking for second kernel');
|
||||
});
|
||||
|
||||
test('Should not find magic when kernel does not match', () => {
|
||||
cellMagicMapper = new CellMagicMapper([sampleLanguageMagicWithKernel]);
|
||||
magic = cellMagicMapper.toLanguageMagic('sampleMagic', 'kernel3');
|
||||
assert.equal(magic, undefined, 'cell magic be undefined when kernel name does not match');
|
||||
assert.strictEqual(magic, undefined, 'cell magic be undefined when kernel name does not match');
|
||||
|
||||
magic = cellMagicMapper.toLanguageMagic('sampleMagic', '');
|
||||
assert.equal(magic, undefined, 'cell magic be undefined when kernel name is empty string');
|
||||
assert.strictEqual(magic, undefined, 'cell magic be undefined when kernel name is empty string');
|
||||
|
||||
magic = cellMagicMapper.toLanguageMagic('sampleMagic', undefined);
|
||||
assert.equal(magic, undefined, 'cell magic be undefined when kernel name is undefined');
|
||||
assert.strictEqual(magic, undefined, 'cell magic be undefined when kernel name is undefined');
|
||||
});
|
||||
|
||||
test('Should not find magic when magic name does not match', () => {
|
||||
cellMagicMapper = new CellMagicMapper([sampleLanguageMagicWithKernel]);
|
||||
magic = cellMagicMapper.toLanguageMagic('sampleMagic1', 'kernel1');
|
||||
assert.equal(magic, undefined, 'cell magic be undefined when magic name does not match');
|
||||
assert.strictEqual(magic, undefined, 'cell magic be undefined when magic name does not match');
|
||||
|
||||
magic = cellMagicMapper.toLanguageMagic('', 'kernel1');
|
||||
assert.equal(magic, undefined, 'cell magic be undefined when magic name is empty string');
|
||||
assert.strictEqual(magic, undefined, 'cell magic be undefined when magic name is empty string');
|
||||
|
||||
magic = cellMagicMapper.toLanguageMagic(undefined, 'kernel1');
|
||||
assert.equal(magic, undefined, 'cell magic be undefined when magic name is undefined');
|
||||
assert.strictEqual(magic, undefined, 'cell magic be undefined when magic name is undefined');
|
||||
});
|
||||
|
||||
test('Should find magic when kernel is not passed in', () => {
|
||||
cellMagicMapper = new CellMagicMapper([sampleLanguageMagicWithoutKernel]);
|
||||
magic = cellMagicMapper.toLanguageMagic('sampleMagicAllKernels', 'kernel1');
|
||||
assert.deepEqual(magic, sampleLanguageMagicWithoutKernel, 'magic should have been found when no kernel was passed in');
|
||||
assert.deepStrictEqual(magic, sampleLanguageMagicWithoutKernel, 'magic should have been found when no kernel was passed in');
|
||||
|
||||
magic = cellMagicMapper.toLanguageMagic('sampleMagic1', 'kernel1');
|
||||
assert.equal(magic, undefined, 'magic should not be found, since magic name does not match');
|
||||
assert.strictEqual(magic, undefined, 'magic should not be found, since magic name does not match');
|
||||
});
|
||||
|
||||
test('Should find magic multiple magics exist for same kernel', () => {
|
||||
cellMagicMapper = new CellMagicMapper([sampleLanguageMagicWithoutKernel, sampleLanguageMagicWithKernel, otherLanguageMagicWithKernel]);
|
||||
magic = cellMagicMapper.toLanguageMagic('sampleMagicAllKernels', 'kernel2');
|
||||
assert.deepEqual(magic, sampleLanguageMagicWithoutKernel, 'magic should have been found when no kernel was passed in');
|
||||
assert.deepStrictEqual(magic, sampleLanguageMagicWithoutKernel, 'magic should have been found when no kernel was passed in');
|
||||
|
||||
magic = cellMagicMapper.toLanguageMagic('sampleMagic', 'kernel2');
|
||||
assert.deepEqual(magic, sampleLanguageMagicWithKernel, 'magic should have been found when kernel was passed in');
|
||||
assert.deepStrictEqual(magic, sampleLanguageMagicWithKernel, 'magic should have been found when kernel was passed in');
|
||||
|
||||
magic = cellMagicMapper.toLanguageMagic('otherMagic', 'kernel2');
|
||||
assert.deepEqual(magic, otherLanguageMagicWithKernel, 'magic should have been found for second magic with kernel passed in');
|
||||
assert.deepStrictEqual(magic, otherLanguageMagicWithKernel, 'magic should have been found for second magic with kernel passed in');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -129,7 +129,7 @@ suite('CellToolbarActions', function (): void {
|
||||
cellModelMock.setup(x => x.cellType).returns(() => 'code');
|
||||
const action = new CellToggleMoreActions(instantiationService);
|
||||
action.onInit(testContainer, contextMock.object);
|
||||
assert.equal(action['_moreActions']['viewItems'][0]['_action']['_actions'].length, 18, 'Unexpected number of valid elements');
|
||||
assert.strictEqual(action['_moreActions']['viewItems'][0]['_action']['_actions'].length, 18, 'Unexpected number of valid elements');
|
||||
});
|
||||
|
||||
test('CellToggleMoreActions with Markdown CellType', function (): void {
|
||||
@@ -138,7 +138,7 @@ suite('CellToolbarActions', function (): void {
|
||||
const action = new CellToggleMoreActions(instantiationService);
|
||||
action.onInit(testContainer, contextMock.object);
|
||||
// Markdown elements don't show the code-cell related actions such as Run Cell
|
||||
assert.equal(action['_moreActions']['viewItems'][0]['_action']['_actions'].length, 7, 'Unexpected number of valid elements');
|
||||
assert.strictEqual(action['_moreActions']['viewItems'][0]['_action']['_actions'].length, 7, 'Unexpected number of valid elements');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -154,29 +154,29 @@ suite('CellToolbarActions', function (): void {
|
||||
test('No notebook model passed in', async function (): Promise<void> {
|
||||
let cellModel = new CellModel({ cell_type: 'code', source: '' }, { isTrusted: true, notebook: undefined });
|
||||
await convertCellAction.doRun({ cell: cellModel, model: undefined });
|
||||
assert.equal(cellModel.cellType, 'code', 'Cell type should not be affected');
|
||||
assert.strictEqual(cellModel.cellType, 'code', 'Cell type should not be affected');
|
||||
});
|
||||
|
||||
test('Convert to code cell', async function (): Promise<void> {
|
||||
await notebookModel.loadContents();
|
||||
await convertCellAction.doRun({ model: notebookModel, cell: notebookModel.cells[0] });
|
||||
assert.equal(notebookModel.cells[0].cellType, 'markdown', 'Cell was not converted correctly');
|
||||
assert.strictEqual(notebookModel.cells[0].cellType, 'markdown', 'Cell was not converted correctly');
|
||||
});
|
||||
|
||||
test('Convert to markdown cell', async function (): Promise<void> {
|
||||
await notebookModel.loadContents();
|
||||
notebookModel.cells[0].cellType = 'markdown';
|
||||
await convertCellAction.doRun({ model: notebookModel, cell: notebookModel.cells[0] });
|
||||
assert.equal(notebookModel.cells[0].cellType, 'code', 'Cell was not converted correctly');
|
||||
assert.strictEqual(notebookModel.cells[0].cellType, 'code', 'Cell was not converted correctly');
|
||||
});
|
||||
|
||||
test('Convert to code cell and back', async function (): Promise<void> {
|
||||
await notebookModel.loadContents();
|
||||
notebookModel.cells[0].cellType = 'markdown';
|
||||
await convertCellAction.doRun({ model: notebookModel, cell: notebookModel.cells[0] });
|
||||
assert.equal(notebookModel.cells[0].cellType, 'code', 'Cell was not converted correctly');
|
||||
assert.strictEqual(notebookModel.cells[0].cellType, 'code', 'Cell was not converted correctly');
|
||||
await convertCellAction.doRun({ model: notebookModel, cell: notebookModel.cells[0] });
|
||||
assert.equal(notebookModel.cells[0].cellType, 'markdown', 'Cell was not converted correctly second time');
|
||||
assert.strictEqual(notebookModel.cells[0].cellType, 'markdown', 'Cell was not converted correctly second time');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -123,9 +123,9 @@ suite('Data Resource Data Provider', function () {
|
||||
serializerStub.restore();
|
||||
|
||||
const noHeadersResult = await fs.readFile(noHeadersFile.fsPath);
|
||||
assert.equal(noHeadersResult.toString(), '1 2 \n3 4 \n', 'result data should not include headers');
|
||||
assert.strictEqual(noHeadersResult.toString(), '1 2 \n3 4 \n', 'result data should not include headers');
|
||||
|
||||
const withHeadersResult = await fs.readFile(withHeadersFile.fsPath);
|
||||
assert.equal(withHeadersResult.toString(), 'col1 col2 \n1 2 \n3 4 \n', 'result data should include headers');
|
||||
assert.strictEqual(withHeadersResult.toString(), 'col1 col2 \n1 2 \n3 4 \n', 'result data should include headers');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -152,14 +152,14 @@ suite('MarkdownTextTransformer', () => {
|
||||
});
|
||||
|
||||
test('Ensure notebook editor returns expected object', async () => {
|
||||
assert.deepEqual(notebookEditor, markdownTextTransformer.notebookEditor, 'Notebook editor does not match expected value');
|
||||
assert.deepStrictEqual(notebookEditor, markdownTextTransformer.notebookEditor, 'Notebook editor does not match expected value');
|
||||
// Set markdown text transformer to not have a notebook editor passed in
|
||||
markdownTextTransformer = new MarkdownTextTransformer(mockNotebookService.object, cellModel);
|
||||
assert.equal(markdownTextTransformer.notebookEditor, undefined, 'No notebook editor should be returned');
|
||||
assert.strictEqual(markdownTextTransformer.notebookEditor, undefined, 'No notebook editor should be returned');
|
||||
// Even after text is attempted to be transformed, there should be no editor, and therefore nothing on the text model
|
||||
await markdownTextTransformer.transformText(MarkdownButtonType.BOLD);
|
||||
assert.equal(markdownTextTransformer.notebookEditor, undefined, 'Notebook model does not have a valid uri, so no editor should be returned');
|
||||
assert.equal(textModel.getValue(), '', 'No text should exist on the textModel');
|
||||
assert.strictEqual(markdownTextTransformer.notebookEditor, undefined, 'Notebook model does not have a valid uri, so no editor should be returned');
|
||||
assert.strictEqual(textModel.getValue(), '', 'No text should exist on the textModel');
|
||||
});
|
||||
|
||||
async function testWithNoSelection(type: MarkdownButtonType, expectedValue: string, setValue = false): Promise<void> {
|
||||
@@ -167,7 +167,7 @@ suite('MarkdownTextTransformer', () => {
|
||||
textModel.setValue('');
|
||||
}
|
||||
await markdownTextTransformer.transformText(type);
|
||||
assert.equal(textModel.getValue(), expectedValue, `${MarkdownButtonType[type]} with no selection failed (setValue ${setValue})`);
|
||||
assert.strictEqual(textModel.getValue(), expectedValue, `${MarkdownButtonType[type]} with no selection failed (setValue ${setValue})`);
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ suite('MarkdownTextTransformer', () => {
|
||||
textModel.setValue('');
|
||||
}
|
||||
await insertFormattedMarkdown('[test](./URL)', widget);
|
||||
assert.equal(textModel.getValue(), expectedValue, `${MarkdownButtonType[type]} with no selection and previously transformed md failed (setValue ${setValue})`);
|
||||
assert.strictEqual(textModel.getValue(), expectedValue, `${MarkdownButtonType[type]} with no selection and previously transformed md failed (setValue ${setValue})`);
|
||||
}
|
||||
|
||||
async function testWithSingleWordSelected(type: MarkdownButtonType, expectedValue: string): Promise<void> {
|
||||
@@ -185,17 +185,17 @@ suite('MarkdownTextTransformer', () => {
|
||||
|
||||
// Test transformation (adding text)
|
||||
widget.setSelection({ startColumn: 1, startLineNumber: 1, endColumn: value.length + 1, endLineNumber: 1 });
|
||||
assert.equal(textModel.getValueInRange(widget.getSelection()), value, 'Expected selection is not found');
|
||||
assert.strictEqual(textModel.getValueInRange(widget.getSelection()), value, 'Expected selection is not found');
|
||||
await markdownTextTransformer.transformText(type);
|
||||
const textModelValue = textModel.getValue();
|
||||
assert.equal(textModelValue, expectedValue, `${MarkdownButtonType[type]} with single word selection failed`);
|
||||
assert.strictEqual(textModelValue, expectedValue, `${MarkdownButtonType[type]} with single word selection failed`);
|
||||
|
||||
// Test undo (removing text)
|
||||
const valueRange = getValueRange(textModel, value);
|
||||
assert.notEqual(valueRange, undefined, 'Could not find value in model after transformation');
|
||||
assert.notStrictEqual(valueRange, undefined, 'Could not find value in model after transformation');
|
||||
widget.setSelection(valueRange);
|
||||
await markdownTextTransformer.transformText(type);
|
||||
assert.equal(textModel.getValue(), value, `Undo operation for ${MarkdownButtonType[type]} with single word selection failed`);
|
||||
assert.strictEqual(textModel.getValue(), value, `Undo operation for ${MarkdownButtonType[type]} with single word selection failed`);
|
||||
}
|
||||
|
||||
async function testPreviouslyTransformedWithSingleWordSelected(type: MarkdownButtonType, expectedValue: string): Promise<void> {
|
||||
@@ -204,44 +204,44 @@ suite('MarkdownTextTransformer', () => {
|
||||
|
||||
// Test transformation (adding text)
|
||||
widget.setSelection({ startColumn: 1, startLineNumber: 1, endColumn: value.length + 1, endLineNumber: 1 });
|
||||
assert.equal(textModel.getValueInRange(widget.getSelection()), value, 'Expected selection is not found');
|
||||
assert.strictEqual(textModel.getValueInRange(widget.getSelection()), value, 'Expected selection is not found');
|
||||
await insertFormattedMarkdown('[SampleURL](https://aka.ms)', widget);
|
||||
const textModelValue = textModel.getValue();
|
||||
assert.equal(textModelValue, expectedValue, `${MarkdownButtonType[type]} with single word selection and previously transformed md failed`);
|
||||
assert.strictEqual(textModelValue, expectedValue, `${MarkdownButtonType[type]} with single word selection and previously transformed md failed`);
|
||||
}
|
||||
|
||||
async function testWithMultipleWordsSelected(type: MarkdownButtonType, expectedValue: string): Promise<void> {
|
||||
let value = 'Multi Words';
|
||||
textModel.setValue(value);
|
||||
widget.setSelection({ startColumn: 1, startLineNumber: 1, endColumn: 12, endLineNumber: 1 });
|
||||
assert.equal(textModel.getValueInRange(widget.getSelection()), value, 'Expected multi-word selection is not found');
|
||||
assert.strictEqual(textModel.getValueInRange(widget.getSelection()), value, 'Expected multi-word selection is not found');
|
||||
await markdownTextTransformer.transformText(type);
|
||||
assert.equal(textModel.getValue(), expectedValue, `${MarkdownButtonType[type]} with multiple word selection failed`);
|
||||
assert.strictEqual(textModel.getValue(), expectedValue, `${MarkdownButtonType[type]} with multiple word selection failed`);
|
||||
|
||||
// Test undo (removing text)
|
||||
const valueRange = getValueRange(textModel, value);
|
||||
assert.notEqual(valueRange, undefined, 'Could not find value in model after transformation');
|
||||
assert.notStrictEqual(valueRange, undefined, 'Could not find value in model after transformation');
|
||||
widget.setSelection(valueRange);
|
||||
await markdownTextTransformer.transformText(type);
|
||||
assert.equal(textModel.getValue(), value, `Undo operation for ${MarkdownButtonType[type]} with multiple word selection failed`);
|
||||
assert.strictEqual(textModel.getValue(), value, `Undo operation for ${MarkdownButtonType[type]} with multiple word selection failed`);
|
||||
}
|
||||
|
||||
async function testWithMultipleLinesSelected(type: MarkdownButtonType, expectedValue: string): Promise<void> {
|
||||
let value = 'Multi\nLines\nSelected';
|
||||
textModel.setValue(value);
|
||||
widget.setSelection({ startColumn: 1, startLineNumber: 1, endColumn: 9, endLineNumber: 3 });
|
||||
assert.equal(textModel.getValueInRange(widget.getSelection()), value, 'Expected multi-line selection is not found');
|
||||
assert.strictEqual(textModel.getValueInRange(widget.getSelection()), value, 'Expected multi-line selection is not found');
|
||||
await markdownTextTransformer.transformText(type);
|
||||
assert.equal(textModel.getValue(), expectedValue, `${MarkdownButtonType[type]} with multiple line selection failed`);
|
||||
assert.strictEqual(textModel.getValue(), expectedValue, `${MarkdownButtonType[type]} with multiple line selection failed`);
|
||||
|
||||
// Test undo (removing text)
|
||||
let valueRange = getValueRange(textModel, 'Multi');
|
||||
// Modify the range to include all the lines
|
||||
valueRange = new Range(valueRange.startLineNumber, valueRange.startColumn, valueRange.endLineNumber + 2, 9);
|
||||
assert.notEqual(valueRange, undefined, 'Could not find value in model after transformation');
|
||||
assert.notStrictEqual(valueRange, undefined, 'Could not find value in model after transformation');
|
||||
widget.setSelection(valueRange);
|
||||
await markdownTextTransformer.transformText(type);
|
||||
assert.equal(textModel.getValue(), value, `Undo operation for ${MarkdownButtonType[type]} with multiple line selection failed`);
|
||||
assert.strictEqual(textModel.getValue(), value, `Undo operation for ${MarkdownButtonType[type]} with multiple line selection failed`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ suite('Test class NotebookEditor:', () => {
|
||||
changeDecorationsCalled = true;
|
||||
return returnObject;
|
||||
});
|
||||
assert.notEqual(changeDecorationsCalled, true, `changeDecorations callback should not have been called`);
|
||||
assert.notStrictEqual(changeDecorationsCalled, true, `changeDecorations callback should not have been called`);
|
||||
assert.notStrictEqual(result, returnObject, 'object returned by the callback given to changeDecorations() call must not be returned by it');
|
||||
assert.strictEqual(result, null, 'return value of changeDecorations() call must be null when no input is set on notebookEditor object');
|
||||
});
|
||||
|
||||
@@ -60,7 +60,7 @@ suite('Notebook Explorer Views', () => {
|
||||
let retrieved = Platform.Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry).getView('notebookView-test-1');
|
||||
assert(d === retrieved, 'Could not register view :' + d.id + 'Retrieved: ' + retrieved);
|
||||
let newCount = Platform.Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry).getViews(NOTEBOOK_VIEW_CONTAINER).length;
|
||||
assert.equal(oldcount + 1, newCount, 'View registration failed');
|
||||
assert.strictEqual(oldcount + 1, newCount, 'View registration failed');
|
||||
|
||||
|
||||
});
|
||||
@@ -89,7 +89,7 @@ suite('Notebook Explorer Views', () => {
|
||||
Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).registerViewlet(v1Duplicate);
|
||||
|
||||
let newCount = Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets().length;
|
||||
assert.equal(oldCount, newCount, 'Duplicate registration of views.');
|
||||
assert.strictEqual(oldCount, newCount, 'Duplicate registration of views.');
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -183,20 +183,20 @@ suite.skip('NotebookService:', function (): void {
|
||||
});
|
||||
|
||||
test('Validate default properties on create', async function (): Promise<void> {
|
||||
assert.equal(notebookService.languageMagics.length, 0, 'No language magics should exist after creation');
|
||||
assert.equal(notebookService.listNotebookEditors().length, 0, 'No notebook editors should be listed');
|
||||
assert.equal(notebookService.getMimeRegistry().mimeTypes.length, 15, 'MIME Types need to have appropriate tests when added or removed');
|
||||
assert.deepEqual(notebookService.getProvidersForFileType('ipynb'), ['sql'], 'sql provider should be registered for ipynb extension');
|
||||
assert.equal(notebookService.getStandardKernelsForProvider('sql').length, 1, 'SQL kernel should be provided by default');
|
||||
assert.equal(notebookService.getStandardKernelsForProvider('otherProvider'), undefined, 'Other provider should not have kernels since it has not been added as a provider');
|
||||
assert.deepEqual(notebookService.getSupportedFileExtensions(), ['IPYNB'], 'IPYNB file extension should be supported by default');
|
||||
assert.strictEqual(notebookService.languageMagics.length, 0, 'No language magics should exist after creation');
|
||||
assert.strictEqual(notebookService.listNotebookEditors().length, 0, 'No notebook editors should be listed');
|
||||
assert.strictEqual(notebookService.getMimeRegistry().mimeTypes.length, 15, 'MIME Types need to have appropriate tests when added or removed');
|
||||
assert.deepStrictEqual(notebookService.getProvidersForFileType('ipynb'), ['sql'], 'sql provider should be registered for ipynb extension');
|
||||
assert.strictEqual(notebookService.getStandardKernelsForProvider('sql').length, 1, 'SQL kernel should be provided by default');
|
||||
assert.strictEqual(notebookService.getStandardKernelsForProvider('otherProvider'), undefined, 'Other provider should not have kernels since it has not been added as a provider');
|
||||
assert.deepStrictEqual(notebookService.getSupportedFileExtensions(), ['IPYNB'], 'IPYNB file extension should be supported by default');
|
||||
await notebookService.registrationComplete;
|
||||
assert.ok(notebookService.isRegistrationComplete, `notebookService.isRegistrationComplete should be true once its registrationComplete promise is resolved`);
|
||||
});
|
||||
|
||||
test('Validate another provider added successfully', async function (): Promise<void> {
|
||||
await notebookService.registrationComplete;
|
||||
assert.deepEqual(notebookService.getProvidersForFileType('ipynb'), ['sql'], 'sql provider should be registered for ipynb extension');
|
||||
assert.deepStrictEqual(notebookService.getProvidersForFileType('ipynb'), ['sql'], 'sql provider should be registered for ipynb extension');
|
||||
|
||||
const otherProviderRegistration: NotebookProviderRegistration = {
|
||||
fileExtensions: 'ipynb',
|
||||
@@ -211,10 +211,10 @@ suite.skip('NotebookService:', function (): void {
|
||||
const notebookRegistry = Registry.as<INotebookProviderRegistry>(Extensions.NotebookProviderContribution);
|
||||
notebookRegistry.registerNotebookProvider(otherProviderRegistration);
|
||||
|
||||
assert.deepEqual(notebookService.getProvidersForFileType('ipynb'), ['sql', 'otherProvider'], 'otherProvider should also be registered for ipynb extension');
|
||||
assert.deepEqual(notebookService.getSupportedFileExtensions(), ['IPYNB'], 'Only IPYNB should be registered as supported file extension');
|
||||
assert.equal(notebookService.getStandardKernelsForProvider('otherProvider').length, 1, 'otherProvider kernel info could not be found');
|
||||
assert.deepEqual(notebookService.getStandardKernelsForProvider('otherProvider')[0], otherProviderRegistration.standardKernels, 'otherProviderRegistration standard kernels does not match');
|
||||
assert.deepStrictEqual(notebookService.getProvidersForFileType('ipynb'), ['sql', 'otherProvider'], 'otherProvider should also be registered for ipynb extension');
|
||||
assert.deepStrictEqual(notebookService.getSupportedFileExtensions(), ['IPYNB'], 'Only IPYNB should be registered as supported file extension');
|
||||
assert.strictEqual(notebookService.getStandardKernelsForProvider('otherProvider').length, 1, 'otherProvider kernel info could not be found');
|
||||
assert.deepStrictEqual(notebookService.getStandardKernelsForProvider('otherProvider')[0], otherProviderRegistration.standardKernels, 'otherProviderRegistration standard kernels does not match');
|
||||
});
|
||||
|
||||
test('tests that dispose() method calls dispose on underlying disposable objects exactly once', async () => {
|
||||
@@ -570,7 +570,7 @@ suite.skip('NotebookService:', function (): void {
|
||||
let getUntitledUriPathSpy = sinon.spy(notebookService, 'getUntitledUriPath');
|
||||
notebookService.getUntitledUriPath('title.ipynb');
|
||||
sinon.assert.calledOnce(getUntitledUriPathSpy);
|
||||
assert.equal(getUntitledUriPathSpy, 'title-0.ipynb');
|
||||
assert.strictEqual(getUntitledUriPathSpy, 'title-0.ipynb');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -96,9 +96,9 @@ suite('NotebookViewModel', function (): void {
|
||||
|
||||
let cellsWithNewView = notebookViews.getCells().filter(cell => cell.views.find(v => v.guid === viewModel.guid));
|
||||
|
||||
assert.equal(cellsWithNewView.length, 2);
|
||||
assert.equal(viewModel.cells.length, 2);
|
||||
assert.equal(viewModel.name, defaultViewName);
|
||||
assert.strictEqual(cellsWithNewView.length, 2);
|
||||
assert.strictEqual(viewModel.cells.length, 2);
|
||||
assert.strictEqual(viewModel.name, defaultViewName);
|
||||
});
|
||||
|
||||
test('initialize notebook with no metadata', async function (): Promise<void> {
|
||||
@@ -108,9 +108,9 @@ suite('NotebookViewModel', function (): void {
|
||||
|
||||
let cellsWithNewView = notebookViews.getCells().filter(cell => cell.views.find(v => v.guid === viewModel.guid));
|
||||
|
||||
assert.equal(cellsWithNewView.length, 2);
|
||||
assert.equal(viewModel.cells.length, 2);
|
||||
assert.equal(viewModel.name, defaultViewName);
|
||||
assert.strictEqual(cellsWithNewView.length, 2);
|
||||
assert.strictEqual(viewModel.cells.length, 2);
|
||||
assert.strictEqual(viewModel.name, defaultViewName);
|
||||
});
|
||||
|
||||
test('rename', async function (): Promise<void> {
|
||||
@@ -125,7 +125,7 @@ suite('NotebookViewModel', function (): void {
|
||||
exceptionThrown = true;
|
||||
}
|
||||
|
||||
assert.equal(view.name, `${defaultViewName} 1`);
|
||||
assert.strictEqual(view.name, `${defaultViewName} 1`);
|
||||
assert(!exceptionThrown);
|
||||
});
|
||||
|
||||
@@ -155,7 +155,7 @@ suite('NotebookViewModel', function (): void {
|
||||
|
||||
viewModel.hideCell(cellToHide);
|
||||
|
||||
assert.equal(viewModel.hiddenCells.length, 1);
|
||||
assert.strictEqual(viewModel.hiddenCells.length, 1);
|
||||
assert(viewModel.hiddenCells.includes(cellToHide));
|
||||
});
|
||||
|
||||
@@ -183,8 +183,8 @@ suite('NotebookViewModel', function (): void {
|
||||
viewModel.moveCell(cellToMove, 98, 99);
|
||||
let cellMeta = viewModel.getCellMetadata(cellToMove);
|
||||
|
||||
assert.equal(cellMeta.x, 98);
|
||||
assert.equal(cellMeta.y, 99);
|
||||
assert.strictEqual(cellMeta.x, 98);
|
||||
assert.strictEqual(cellMeta.y, 99);
|
||||
});
|
||||
|
||||
test('resize cell', async function (): Promise<void> {
|
||||
@@ -197,8 +197,8 @@ suite('NotebookViewModel', function (): void {
|
||||
viewModel.resizeCell(cellToResize, 3, 4);
|
||||
let cellMeta = viewModel.getCellMetadata(cellToResize);
|
||||
|
||||
assert.equal(cellMeta.width, 3);
|
||||
assert.equal(cellMeta.height, 4);
|
||||
assert.strictEqual(cellMeta.width, 3);
|
||||
assert.strictEqual(cellMeta.height, 4);
|
||||
});
|
||||
|
||||
test('get cell metadata', async function (): Promise<void> {
|
||||
@@ -210,7 +210,7 @@ suite('NotebookViewModel', function (): void {
|
||||
let cellMeta = notebookViews.getCellMetadata(cell);
|
||||
|
||||
assert(!isUndefinedOrNull(cellMeta.views.find(v => v.guid === viewModel.guid)));
|
||||
assert.deepEqual(viewModel.getCellMetadata(cell), cellMeta.views.find(v => v.guid === viewModel.guid));
|
||||
assert.deepStrictEqual(viewModel.getCellMetadata(cell), cellMeta.views.find(v => v.guid === viewModel.guid));
|
||||
});
|
||||
|
||||
test('delete', async function (): Promise<void> {
|
||||
|
||||
@@ -76,14 +76,14 @@ suite('NotebookViews', function (): void {
|
||||
});
|
||||
|
||||
test('create new view', async function (): Promise<void> {
|
||||
assert.equal(notebookViews.getViews().length, 0, 'notebook should not initially generate any views');
|
||||
assert.strictEqual(notebookViews.getViews().length, 0, 'notebook should not initially generate any views');
|
||||
|
||||
let newView = notebookViews.createNewView(defaultViewName);
|
||||
let cellsWithMatchingGuid = newView.cells.filter(cell => newView.getCellMetadata(cell).guid === newView.guid);
|
||||
|
||||
assert.equal(newView.name, defaultViewName, 'view was not created with its given name');
|
||||
assert.equal(newView.cells.length, 2, 'view did not contain the same number of cells as the notebook used to create it');
|
||||
assert.equal(cellsWithMatchingGuid.length, newView.cells.length, 'cell metadata was not created for all cells in view');
|
||||
assert.strictEqual(newView.name, defaultViewName, 'view was not created with its given name');
|
||||
assert.strictEqual(newView.cells.length, 2, 'view did not contain the same number of cells as the notebook used to create it');
|
||||
assert.strictEqual(cellsWithMatchingGuid.length, newView.cells.length, 'cell metadata was not created for all cells in view');
|
||||
});
|
||||
|
||||
test('remove view', async function (): Promise<void> {
|
||||
@@ -93,23 +93,23 @@ suite('NotebookViews', function (): void {
|
||||
|
||||
let cellsWithNewView = notebookViews.getCells().filter(cell => cell.views.find(v => v.guid === newView.guid));
|
||||
|
||||
assert.equal(notebookViews.getViews().length, 0, 'view not removed from notebook metadata');
|
||||
assert.equal(cellsWithNewView.length, 0, 'view not removed from cells');
|
||||
assert.strictEqual(notebookViews.getViews().length, 0, 'view not removed from notebook metadata');
|
||||
assert.strictEqual(cellsWithNewView.length, 0, 'view not removed from cells');
|
||||
});
|
||||
|
||||
test('default view name', async function (): Promise<void> {
|
||||
let newView = notebookViews.createNewView();
|
||||
assert.equal(newView.name, NotebookViewsExtension.defaultViewName);
|
||||
assert.strictEqual(newView.name, NotebookViewsExtension.defaultViewName);
|
||||
|
||||
let newView1 = notebookViews.createNewView();
|
||||
assert.equal(newView1.name, `${NotebookViewsExtension.defaultViewName} 1`);
|
||||
assert.strictEqual(newView1.name, `${NotebookViewsExtension.defaultViewName} 1`);
|
||||
});
|
||||
|
||||
test('active view', async function (): Promise<void> {
|
||||
let newView = notebookViews.createNewView();
|
||||
notebookViews.setActiveView(newView);
|
||||
|
||||
assert.equal(notebookViews.getActiveView(), newView);
|
||||
assert.strictEqual(notebookViews.getActiveView(), newView);
|
||||
});
|
||||
|
||||
test('update cell', async function (): Promise<void> {
|
||||
|
||||
@@ -6,26 +6,25 @@
|
||||
import * as assert from 'assert';
|
||||
import { nb } from 'azdata';
|
||||
import * as op from 'sql/workbench/contrib/notebook/browser/models/outputProcessor';
|
||||
import { JSONObject } from 'sql/workbench/services/notebook/common/jsonext';
|
||||
import { nbformat as nbformat } from 'sql/workbench/services/notebook/common/nbformat';
|
||||
|
||||
suite('OutputProcessor functions', function (): void {
|
||||
const text = 'An arbitrary text input:!@#$%^&*()_+~`:;,.-_=';
|
||||
|
||||
const arbitraryMetadata = {
|
||||
// arbitrarily construction chart options. It is any JSONObject
|
||||
azdata_chartOptions: {
|
||||
scale: true,
|
||||
dataGrid: false,
|
||||
arbitraryCharProperty: {
|
||||
prop1: 'value1',
|
||||
prop2: {
|
||||
deepProp1: 3
|
||||
}
|
||||
const arbitraryMetadata = Object.create(null); // Use null prototype in order to pass strict deepEqual assertions
|
||||
arbitraryMetadata['azdata_chartOptions'] = {
|
||||
'scale': true,
|
||||
'dataGrid': false,
|
||||
'arbitraryCharProperty': {
|
||||
'prop1': 'value1',
|
||||
'prop2': {
|
||||
'deepProp1': 3
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const emptyMetadata = Object.create(null);
|
||||
|
||||
suite('getData', function (): void {
|
||||
// data tests
|
||||
for (const outputType of ['execute_result', 'display_data', 'update_display_data'] as nbformat.OutputType[]) {
|
||||
@@ -79,9 +78,9 @@ suite('OutputProcessor functions', function (): void {
|
||||
output.metadata = arbitraryMetadata;
|
||||
const result = op.getMetadata(output);
|
||||
if (nbformat.isExecuteResult(output) || nbformat.isDisplayData(output)) {
|
||||
assert.deepEqual(result, output.metadata, `getMetadata should return the metadata object passed in the output object`);
|
||||
assert.deepStrictEqual(result, output.metadata, `getMetadata should return the metadata object passed in the output object`);
|
||||
} else {
|
||||
assert.deepEqual(result, {}, `getMetadata should return an empty object when output_type is not IDisplayData or IExecuteResult`);
|
||||
assert.deepStrictEqual(result, emptyMetadata, `getMetadata should return an empty object when output_type is not IDisplayData or IExecuteResult`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -105,7 +104,7 @@ suite('OutputProcessor functions', function (): void {
|
||||
metadata: op.getMetadata(output),
|
||||
trusted: trusted
|
||||
};
|
||||
assert.deepEqual(result, expected, `getBundleOptions should return an object that has data and metadata fields as returned by getData and getMetadata calls and a trusted field as the value of the 'trusted' field in options passed to it`);
|
||||
assert.deepStrictEqual(result, expected, `getBundleOptions should return an object that has data and metadata fields as returned by getData and getMetadata calls and a trusted field as the value of the 'trusted' field in options passed to it`);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -114,22 +113,24 @@ suite('OutputProcessor functions', function (): void {
|
||||
|
||||
function verifyGetDataForDataOutput(output: nbformat.IExecuteResult | nbformat.IDisplayData | nbformat.IDisplayUpdate) {
|
||||
const result = op.getData(output);
|
||||
const expectedData = Object.create(null);
|
||||
for (let key in output.data) {
|
||||
expectedData[key] = output.data[key];
|
||||
}
|
||||
// getData just returns the data property object for ExecutionResults/DisplayData/DisplayUpdate Output object sent to it.
|
||||
assert.deepEqual(result, output.data, `getData should return the expectedData:${output.data} object`);
|
||||
assert.deepStrictEqual(result, expectedData, `getData should return the expectedData: '${JSON.stringify(expectedData)}' object`);
|
||||
}
|
||||
|
||||
function verifyGetDataForStreamOutput(output: nbformat.IStream): void {
|
||||
// expected return value is an object with a single property of 'application/vnd.jupyter.stderr' or 'application/vnd.jupyter.stdout'
|
||||
// corresponding to the stream name. The value of this property is the value of the 'text' field of the output object that was sent into the getData call
|
||||
const expectedData = output.name === 'stderr'
|
||||
? {
|
||||
'application/vnd.jupyter.stderr': output.text,
|
||||
}
|
||||
: {
|
||||
'application/vnd.jupyter.stdout': output.text,
|
||||
};
|
||||
let expectedStdErr = Object.create(null);
|
||||
expectedStdErr['application/vnd.jupyter.stderr'] = output.text;
|
||||
let expectedStdOut = Object.create(null);
|
||||
expectedStdOut['application/vnd.jupyter.stdout'] = output.text;
|
||||
const expectedData = output.name === 'stderr' ? expectedStdErr : expectedStdOut;
|
||||
const result = op.getData(output);
|
||||
assert.deepEqual(result, expectedData, `getData should return the expectedData:${expectedData} object`);
|
||||
assert.deepStrictEqual(result, expectedData, `getData should return the expectedData: '${JSON.stringify(expectedData)}' object`);
|
||||
}
|
||||
|
||||
function verifyGetDataForErrorOutput(output: nbformat.IError): void {
|
||||
@@ -139,25 +140,19 @@ function verifyGetDataForErrorOutput(output: nbformat.IError): void {
|
||||
// this property is assigned to a '\n' delimited traceback data when it is present.
|
||||
// when traceback is absent this property gets ename and evalue information with ': ' as delimiter unless
|
||||
// ename is empty in which case it is just evalue information.
|
||||
let expectedData: JSONObject = {
|
||||
'application/vnd.jupyter.stderr': undefined
|
||||
};
|
||||
let expectedData = Object.create(null);
|
||||
expectedData['application/vnd.jupyter.stderr'] = undefined;
|
||||
|
||||
if (tracedata) {
|
||||
expectedData = {
|
||||
'application/vnd.jupyter.stderr': tracedata
|
||||
};
|
||||
expectedData['application/vnd.jupyter.stderr'] = tracedata;
|
||||
}
|
||||
else if (output.evalue) {
|
||||
if (output.ename !== undefined && output.ename !== '') {
|
||||
expectedData = {
|
||||
'application/vnd.jupyter.stderr': `${output.ename}: ${output.evalue}`
|
||||
};
|
||||
expectedData['application/vnd.jupyter.stderr'] = `${output.ename}: ${output.evalue}`;
|
||||
}
|
||||
else {
|
||||
expectedData = {
|
||||
'application/vnd.jupyter.stderr': `${output.evalue}`
|
||||
};
|
||||
expectedData['application/vnd.jupyter.stderr'] = `${output.evalue}`;
|
||||
}
|
||||
}
|
||||
assert.deepEqual(result, <JSONObject>expectedData, `getData should return the expectedData:'${JSON.stringify(expectedData)}' object`);
|
||||
assert.deepStrictEqual(result, expectedData, `getData should return the expectedData: '${JSON.stringify(expectedData)}' object`);
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ suite('Image Callout Dialog', function (): void {
|
||||
imageCalloutDialog.cancel();
|
||||
let result = await deferred.promise;
|
||||
|
||||
assert.equal(result.imagePath, undefined, 'ImagePath must be undefined');
|
||||
assert.equal(result.embedImage, undefined, 'EmbedImage must be undefined');
|
||||
assert.equal(result.insertEscapedMarkdown, '', 'Markdown not returned correctly');
|
||||
assert.strictEqual(result.imagePath, undefined, 'ImagePath must be undefined');
|
||||
assert.strictEqual(result.embedImage, undefined, 'EmbedImage must be undefined');
|
||||
assert.strictEqual(result.insertEscapedMarkdown, '', 'Markdown not returned correctly');
|
||||
});
|
||||
|
||||
test('Should return expected values on insert', async function (): Promise<void> {
|
||||
@@ -69,9 +69,9 @@ suite('Image Callout Dialog', function (): void {
|
||||
// And insert the dialog
|
||||
imageCalloutDialog.insert();
|
||||
let result = await deferred.promise;
|
||||
assert.equal(result.imagePath, sampleImageFileUrl.fsPath, 'ImagePath not returned correctly');
|
||||
assert.equal(result.embedImage, false, 'EmbedImage not returned correctly');
|
||||
assert.equal(result.insertEscapedMarkdown, ``, 'Markdown not returned correctly');
|
||||
assert.strictEqual(result.imagePath, sampleImageFileUrl.fsPath, 'ImagePath not returned correctly');
|
||||
assert.strictEqual(result.embedImage, false, 'EmbedImage not returned correctly');
|
||||
assert.strictEqual(result.insertEscapedMarkdown, ``, 'Markdown not returned correctly');
|
||||
});
|
||||
|
||||
test('Should return expected values on insert when imageName has space', async function (): Promise<void> {
|
||||
@@ -91,9 +91,9 @@ suite('Image Callout Dialog', function (): void {
|
||||
// And insert the dialog
|
||||
imageCalloutDialog.insert();
|
||||
let result = await deferred.promise;
|
||||
assert.equal(result.imagePath, sampleImageFileUrl.fsPath, 'imagePath not returned correctly');
|
||||
assert.equal(result.embedImage, false, 'embedImage not returned correctly');
|
||||
assert.equal(result.insertEscapedMarkdown, `})`, 'Markdown not returned correctly');
|
||||
assert.strictEqual(result.imagePath, sampleImageFileUrl.fsPath, 'imagePath not returned correctly');
|
||||
assert.strictEqual(result.embedImage, false, 'embedImage not returned correctly');
|
||||
assert.strictEqual(result.insertEscapedMarkdown, `})`, 'Markdown not returned correctly');
|
||||
});
|
||||
|
||||
test('Should return expected values on insert when add as attachment is set', async function (): Promise<void> {
|
||||
@@ -115,9 +115,9 @@ suite('Image Callout Dialog', function (): void {
|
||||
// And insert the dialog
|
||||
imageCalloutDialog.insert();
|
||||
let result = await deferred.promise;
|
||||
assert.equal(result.imagePath, sampleImageFileUrl.fsPath, 'imagePath not returned correctly');
|
||||
assert.equal(result.embedImage, true, 'embedImage not returned correctly');
|
||||
assert.equal(result.insertEscapedMarkdown, ``, 'Markdown not returned correctly');
|
||||
assert.strictEqual(result.imagePath, sampleImageFileUrl.fsPath, 'imagePath not returned correctly');
|
||||
assert.strictEqual(result.embedImage, true, 'embedImage not returned correctly');
|
||||
assert.strictEqual(result.insertEscapedMarkdown, ``, 'Markdown not returned correctly');
|
||||
});
|
||||
|
||||
test('Should return expected values on insert when imageName has space and add attachment is set', async function (): Promise<void> {
|
||||
@@ -139,9 +139,9 @@ suite('Image Callout Dialog', function (): void {
|
||||
// And insert the dialog
|
||||
imageCalloutDialog.insert();
|
||||
let result = await deferred.promise;
|
||||
assert.equal(result.imagePath, sampleImageFileUrl.fsPath, 'imagePath not returned correctly');
|
||||
assert.equal(result.embedImage, true, 'embedImage not returned correctly');
|
||||
assert.equal(result.insertEscapedMarkdown, `})`, 'Markdown not returned correctly');
|
||||
assert.strictEqual(result.imagePath, sampleImageFileUrl.fsPath, 'imagePath not returned correctly');
|
||||
assert.strictEqual(result.embedImage, true, 'embedImage not returned correctly');
|
||||
assert.strictEqual(result.insertEscapedMarkdown, `})`, 'Markdown not returned correctly');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -9,34 +9,34 @@ import { isPrimitive } from 'sql/workbench/services/notebook/common/jsonext';
|
||||
suite('jsonext', function (): void {
|
||||
test('Validate null object is primitive', async function (): Promise<void> {
|
||||
let object = null;
|
||||
assert.equal(isPrimitive(object), true, 'null object should be primitive');
|
||||
assert.strictEqual(isPrimitive(object), true, 'null object should be primitive');
|
||||
object = undefined;
|
||||
assert.equal(isPrimitive(object), false, 'undefined object should not be primitive');
|
||||
assert.strictEqual(isPrimitive(object), false, 'undefined object should not be primitive');
|
||||
});
|
||||
test('Validate boolean types are primitive', async function (): Promise<void> {
|
||||
let object: boolean = false;
|
||||
assert.equal(isPrimitive(object), true, 'false boolean object should be primitive');
|
||||
assert.strictEqual(isPrimitive(object), true, 'false boolean object should be primitive');
|
||||
object = true;
|
||||
assert.equal(isPrimitive(object), true, 'true boolean object should be primitive');
|
||||
assert.strictEqual(isPrimitive(object), true, 'true boolean object should be primitive');
|
||||
});
|
||||
test('Validate number types are primitive', async function (): Promise<void> {
|
||||
let object: number = 0;
|
||||
assert.equal(isPrimitive(object), true, 'number with value 0 should be primitive');
|
||||
assert.strictEqual(isPrimitive(object), true, 'number with value 0 should be primitive');
|
||||
object = 1;
|
||||
assert.equal(isPrimitive(object), true, 'number with value 1 should be primitive');
|
||||
assert.strictEqual(isPrimitive(object), true, 'number with value 1 should be primitive');
|
||||
});
|
||||
test('Validate string types are primitive', async function (): Promise<void> {
|
||||
let object: string = '';
|
||||
assert.equal(isPrimitive(object), true, 'empty strings should be primitive');
|
||||
assert.strictEqual(isPrimitive(object), true, 'empty strings should be primitive');
|
||||
object = 'nonempty string';
|
||||
assert.equal(isPrimitive(object), true, 'non-empty strings should be primitive');
|
||||
assert.strictEqual(isPrimitive(object), true, 'non-empty strings should be primitive');
|
||||
});
|
||||
test('custom object is not primitive', async function (): Promise<void> {
|
||||
let object = {
|
||||
prop1: 'val1'
|
||||
};
|
||||
assert.equal(isPrimitive(object), false, 'custom object should not be primitive');
|
||||
assert.strictEqual(isPrimitive(object), false, 'custom object should not be primitive');
|
||||
object = undefined;
|
||||
assert.equal(isPrimitive(object), false, 'undefined object should not be primitive');
|
||||
assert.strictEqual(isPrimitive(object), false, 'undefined object should not be primitive');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,42 +17,42 @@ suite('nbformat', function (): void {
|
||||
};
|
||||
test('Validate display_data Output Type', async function (): Promise<void> {
|
||||
sampleOutput.output_type = 'display_data';
|
||||
assert.equal(nbformat.isDisplayData(sampleOutput), true, 'display_data output type not recognized correctly');
|
||||
assert.equal(nbformat.isDisplayUpdate(sampleOutput), false, 'update_display_data output type incorrectly recognized');
|
||||
assert.equal(nbformat.isError(sampleOutput), false, 'error output type incorrectly recognized');
|
||||
assert.equal(nbformat.isExecuteResult(sampleOutput), false, 'execute_result output type incorrectly recognized');
|
||||
assert.equal(nbformat.isStream(sampleOutput), false, 'stream output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isDisplayData(sampleOutput), true, 'display_data output type not recognized correctly');
|
||||
assert.strictEqual(nbformat.isDisplayUpdate(sampleOutput), false, 'update_display_data output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isError(sampleOutput), false, 'error output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isExecuteResult(sampleOutput), false, 'execute_result output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isStream(sampleOutput), false, 'stream output type incorrectly recognized');
|
||||
});
|
||||
test('Validate update_display_data Output Type', async function (): Promise<void> {
|
||||
sampleOutput.output_type = 'update_display_data';
|
||||
assert.equal(nbformat.isDisplayData(sampleOutput), false, 'display_data output type incorrectly recognized');
|
||||
assert.equal(nbformat.isDisplayUpdate(sampleOutput), true, 'update_display_data output type not recognized correctly');
|
||||
assert.equal(nbformat.isError(sampleOutput), false, 'error output type incorrectly recognized');
|
||||
assert.equal(nbformat.isExecuteResult(sampleOutput), false, 'execute_result output type incorrectly recognized');
|
||||
assert.equal(nbformat.isStream(sampleOutput), false, 'stream output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isDisplayData(sampleOutput), false, 'display_data output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isDisplayUpdate(sampleOutput), true, 'update_display_data output type not recognized correctly');
|
||||
assert.strictEqual(nbformat.isError(sampleOutput), false, 'error output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isExecuteResult(sampleOutput), false, 'execute_result output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isStream(sampleOutput), false, 'stream output type incorrectly recognized');
|
||||
});
|
||||
test('Validate error Output Type', async function (): Promise<void> {
|
||||
sampleOutput.output_type = 'error';
|
||||
assert.equal(nbformat.isDisplayData(sampleOutput), false, 'display_data output type incorrectly recognized');
|
||||
assert.equal(nbformat.isDisplayUpdate(sampleOutput), false, 'update_display_data output type incorrectly recognized');
|
||||
assert.equal(nbformat.isError(sampleOutput), true, 'error output type not recognized correctly');
|
||||
assert.equal(nbformat.isExecuteResult(sampleOutput), false, 'execute_result output type incorrectly recognized');
|
||||
assert.equal(nbformat.isStream(sampleOutput), false, 'stream output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isDisplayData(sampleOutput), false, 'display_data output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isDisplayUpdate(sampleOutput), false, 'update_display_data output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isError(sampleOutput), true, 'error output type not recognized correctly');
|
||||
assert.strictEqual(nbformat.isExecuteResult(sampleOutput), false, 'execute_result output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isStream(sampleOutput), false, 'stream output type incorrectly recognized');
|
||||
});
|
||||
test('Validate execute_result Output Type', async function (): Promise<void> {
|
||||
sampleOutput.output_type = 'execute_result';
|
||||
assert.equal(nbformat.isDisplayData(sampleOutput), false, 'display_data output type incorrectly recognized');
|
||||
assert.equal(nbformat.isDisplayUpdate(sampleOutput), false, 'update_display_data output type incorrectly recognized');
|
||||
assert.equal(nbformat.isError(sampleOutput), false, 'error output type incorrectly recognized');
|
||||
assert.equal(nbformat.isExecuteResult(sampleOutput), true, 'execute_result output type not recognized correctly');
|
||||
assert.equal(nbformat.isStream(sampleOutput), false, 'stream output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isDisplayData(sampleOutput), false, 'display_data output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isDisplayUpdate(sampleOutput), false, 'update_display_data output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isError(sampleOutput), false, 'error output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isExecuteResult(sampleOutput), true, 'execute_result output type not recognized correctly');
|
||||
assert.strictEqual(nbformat.isStream(sampleOutput), false, 'stream output type incorrectly recognized');
|
||||
});
|
||||
test('Validate stream Output Type', async function (): Promise<void> {
|
||||
sampleOutput.output_type = 'stream';
|
||||
assert.equal(nbformat.isDisplayData(sampleOutput), false, 'display_data output type incorrectly recognized');
|
||||
assert.equal(nbformat.isDisplayUpdate(sampleOutput), false, 'update_display_data output type incorrectly recognized');
|
||||
assert.equal(nbformat.isError(sampleOutput), false, 'error output type incorrectly recognized');
|
||||
assert.equal(nbformat.isExecuteResult(sampleOutput), false, 'execute_result output type incorrectly recognized');
|
||||
assert.equal(nbformat.isStream(sampleOutput), true, 'stream output type not recognized correctly');
|
||||
assert.strictEqual(nbformat.isDisplayData(sampleOutput), false, 'display_data output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isDisplayUpdate(sampleOutput), false, 'update_display_data output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isError(sampleOutput), false, 'error output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isExecuteResult(sampleOutput), false, 'execute_result output type incorrectly recognized');
|
||||
assert.strictEqual(nbformat.isStream(sampleOutput), true, 'stream output type not recognized correctly');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,16 +36,16 @@ suite('Cell Model', function (): void {
|
||||
let factory = new ModelFactory(instantiationService);
|
||||
test('Should set default values if none defined', async function (): Promise<void> {
|
||||
let cell = factory.createCell(undefined, undefined);
|
||||
assert.equal(cell.cellType, CellTypes.Code);
|
||||
assert.equal(cell.source, '');
|
||||
assert.strictEqual(cell.cellType, CellTypes.Code);
|
||||
assert.strictEqual(cell.source, '');
|
||||
});
|
||||
|
||||
test('Should update values', async function (): Promise<void> {
|
||||
let cell = factory.createCell(undefined, undefined);
|
||||
cell.setOverrideLanguage('sql');
|
||||
assert.equal(cell.language, 'sql');
|
||||
assert.strictEqual(cell.language, 'sql');
|
||||
cell.source = 'abcd';
|
||||
assert.equal(JSON.stringify(cell.source), JSON.stringify(['abcd']));
|
||||
assert.strictEqual(JSON.stringify(cell.source), JSON.stringify(['abcd']));
|
||||
});
|
||||
|
||||
test('Should match ICell values if defined', async function (): Promise<void> {
|
||||
@@ -62,11 +62,11 @@ suite('Cell Model', function (): void {
|
||||
execution_count: 1
|
||||
};
|
||||
let cell = factory.createCell(cellData, undefined);
|
||||
assert.equal(cell.cellType, cellData.cell_type);
|
||||
assert.equal(JSON.stringify(cell.source), JSON.stringify([cellData.source]));
|
||||
assert.equal(cell.outputs.length, 1);
|
||||
assert.equal(cell.outputs[0].output_type, 'stream');
|
||||
assert.equal((<nb.IStreamResult>cell.outputs[0]).text, 'Some output');
|
||||
assert.strictEqual(cell.cellType, cellData.cell_type);
|
||||
assert.strictEqual(JSON.stringify(cell.source), JSON.stringify([cellData.source]));
|
||||
assert.strictEqual(cell.outputs.length, 1);
|
||||
assert.strictEqual(cell.outputs[0].output_type, 'stream');
|
||||
assert.strictEqual((<nb.IStreamResult>cell.outputs[0]).text, 'Some output');
|
||||
});
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ suite('Cell Model', function (): void {
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
assert.equal(cell.language, 'python');
|
||||
assert.strictEqual(cell.language, 'python');
|
||||
});
|
||||
|
||||
test('Should set cell language to python if defined as pyspark in languageInfo', async function (): Promise<void> {
|
||||
@@ -101,7 +101,7 @@ suite('Cell Model', function (): void {
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
assert.equal(cell.language, 'python');
|
||||
assert.strictEqual(cell.language, 'python');
|
||||
});
|
||||
|
||||
test('Should keep cell language as python if cell has language override', async function (): Promise<void> {
|
||||
@@ -118,7 +118,7 @@ suite('Cell Model', function (): void {
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
assert.equal(cell.language, 'python');
|
||||
assert.strictEqual(cell.language, 'python');
|
||||
});
|
||||
|
||||
test('Should set cell language to python if no language defined', async function (): Promise<void> {
|
||||
@@ -135,7 +135,7 @@ suite('Cell Model', function (): void {
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
assert.equal(cell.language, 'python');
|
||||
assert.strictEqual(cell.language, 'python');
|
||||
});
|
||||
|
||||
test('Should allow source of type string[] with length 1', async function (): Promise<void> {
|
||||
@@ -153,8 +153,8 @@ suite('Cell Model', function (): void {
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
assert(Array.isArray(cell.source));
|
||||
assert.equal(cell.source.length, 1);
|
||||
assert.equal(cell.source[0], 'print(1)');
|
||||
assert.strictEqual(cell.source.length, 1);
|
||||
assert.strictEqual(cell.source[0], 'print(1)');
|
||||
});
|
||||
|
||||
test('Should allow source of type string', async function (): Promise<void> {
|
||||
@@ -172,7 +172,7 @@ suite('Cell Model', function (): void {
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
assert(Array.isArray(cell.source));
|
||||
assert.equal(JSON.stringify(cell.source), JSON.stringify(['print(1)']));
|
||||
assert.strictEqual(JSON.stringify(cell.source), JSON.stringify(['print(1)']));
|
||||
});
|
||||
|
||||
test('Should allow source of type string with newline and split it', async function (): Promise<void> {
|
||||
@@ -190,9 +190,9 @@ suite('Cell Model', function (): void {
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
assert(Array.isArray(cell.source));
|
||||
assert.equal(cell.source.length, 2);
|
||||
assert.equal(cell.source[0], 'print(1)\n');
|
||||
assert.equal(cell.source[1], 'print(2)');
|
||||
assert.strictEqual(cell.source.length, 2);
|
||||
assert.strictEqual(cell.source[0], 'print(1)\n');
|
||||
assert.strictEqual(cell.source[1], 'print(2)');
|
||||
});
|
||||
|
||||
test('Should allow source of type string with Windows style newline and split it', async function (): Promise<void> {
|
||||
@@ -210,9 +210,9 @@ suite('Cell Model', function (): void {
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
assert(Array.isArray(cell.source));
|
||||
assert.equal(cell.source.length, 2);
|
||||
assert.equal(cell.source[0], 'print(1)\r\n');
|
||||
assert.equal(cell.source[1], 'print(2)');
|
||||
assert.strictEqual(cell.source.length, 2);
|
||||
assert.strictEqual(cell.source[0], 'print(1)\r\n');
|
||||
assert.strictEqual(cell.source[1], 'print(2)');
|
||||
});
|
||||
|
||||
test('Should allow source of type string[] with length 2', async function (): Promise<void> {
|
||||
@@ -230,9 +230,9 @@ suite('Cell Model', function (): void {
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
assert(Array.isArray(cell.source));
|
||||
assert.equal(cell.source.length, 2);
|
||||
assert.equal(cell.source[0], 'print(1)\n');
|
||||
assert.equal(cell.source[1], 'print(2)');
|
||||
assert.strictEqual(cell.source.length, 2);
|
||||
assert.strictEqual(cell.source[0], 'print(1)\n');
|
||||
assert.strictEqual(cell.source[1], 'print(2)');
|
||||
});
|
||||
|
||||
test('Should allow empty string source', async function (): Promise<void> {
|
||||
@@ -250,7 +250,7 @@ suite('Cell Model', function (): void {
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
assert(Array.isArray(cell.source));
|
||||
assert.equal(JSON.stringify(cell.source), JSON.stringify(['']));
|
||||
assert.strictEqual(JSON.stringify(cell.source), JSON.stringify(['']));
|
||||
});
|
||||
|
||||
test('Should parse metadata\'s hide_input tag correctly', async function (): Promise<void> {
|
||||
@@ -571,7 +571,7 @@ suite('Cell Model', function (): void {
|
||||
cell.setFuture(future.object);
|
||||
|
||||
// Then I expect outputs to have been cleared
|
||||
assert.equal(outputs.length, 0);
|
||||
assert.strictEqual(outputs.length, 0);
|
||||
assert(!isUndefinedOrNull(onReply));
|
||||
// ... And when I send an IoPub message
|
||||
let message: nb.IIOPubMessage = {
|
||||
@@ -588,13 +588,13 @@ suite('Cell Model', function (): void {
|
||||
};
|
||||
onIopub.handle(message);
|
||||
// Then I expect an output to be added
|
||||
assert.equal(outputs.length, 1);
|
||||
assert.equal(outputs[0].output_type, 'stream');
|
||||
assert.strictEqual(outputs.length, 1);
|
||||
assert.strictEqual(outputs[0].output_type, 'stream');
|
||||
|
||||
message = objects.deepClone(message);
|
||||
message.header.msg_type = 'display_data';
|
||||
onIopub.handle(message);
|
||||
assert.equal(outputs[1].output_type, 'display_data');
|
||||
assert.strictEqual(outputs[1].output_type, 'display_data');
|
||||
});
|
||||
|
||||
test('stdin should return void if no handler registered', async () => {
|
||||
@@ -636,8 +636,8 @@ suite('Cell Model', function (): void {
|
||||
await result;
|
||||
// And I expect message to have been passed upstream and no message sent from the cell
|
||||
assert(!isUndefinedOrNull(stdInMessage));
|
||||
assert.equal(stdInMessage.content.prompt, stdInDefaultMessage.content.prompt);
|
||||
assert.equal(stdInMessage.content.password, stdInDefaultMessage.content.password);
|
||||
assert.strictEqual(stdInMessage.content.prompt, stdInDefaultMessage.content.prompt);
|
||||
assert.strictEqual(stdInMessage.content.password, stdInDefaultMessage.content.password);
|
||||
future.verify(f => f.sendInputReply(TypeMoq.It.isAny()), TypeMoq.Times.never());
|
||||
});
|
||||
test('stdin should send default response if there is upstream error', async () => {
|
||||
@@ -688,7 +688,7 @@ suite('Cell Model', function (): void {
|
||||
onIopub.handle(message);
|
||||
//Output array's length should be 1
|
||||
//'transient' tag should no longer exist in the output
|
||||
assert.equal(outputs.length, 1);
|
||||
assert.strictEqual(outputs.length, 1);
|
||||
assert(isUndefinedOrNull(outputs[0]['transient']));
|
||||
});
|
||||
|
||||
@@ -710,7 +710,7 @@ suite('Cell Model', function (): void {
|
||||
|
||||
let cell = factory.createCell(undefined, { notebook: notebookModel, isTrusted: false });
|
||||
assert(!isUndefinedOrNull(cell.cellGuid));
|
||||
assert.equal(cell.cellGuid.length, 36);
|
||||
assert.strictEqual(cell.cellGuid.length, 36);
|
||||
let cellJson = cell.toJSON();
|
||||
assert(!isUndefinedOrNull(cellJson.metadata.azdata_cell_guid));
|
||||
});
|
||||
@@ -739,7 +739,7 @@ suite('Cell Model', function (): void {
|
||||
let cell = factory.createCell(undefined, { notebook: notebookModel, isTrusted: false });
|
||||
let content = JSON.stringify(cell.toJSON(), undefined, ' ');
|
||||
let contentSplit = content.split('\n');
|
||||
assert.equal(contentSplit.length, 9);
|
||||
assert.strictEqual(contentSplit.length, 9);
|
||||
assert(contentSplit[0].trim().startsWith('{'));
|
||||
assert(contentSplit[1].trim().startsWith('"cell_type": "code",'));
|
||||
assert(contentSplit[2].trim().startsWith('"source": ""'));
|
||||
@@ -1038,7 +1038,7 @@ suite('Cell Model', function (): void {
|
||||
metadata: { connection_name: connectionName }
|
||||
};
|
||||
let model = factory.createCell(contents, { notebook: notebookModel, isTrusted: false });
|
||||
assert.equal(model.savedConnectionName, connectionName);
|
||||
assert.strictEqual(model.savedConnectionName, connectionName);
|
||||
});
|
||||
|
||||
test('Should read attachments name from notebook attachments', async function () {
|
||||
@@ -1054,10 +1054,10 @@ suite('Cell Model', function (): void {
|
||||
attachments: cellAttachment
|
||||
};
|
||||
let model = factory.createCell(contents, { notebook: notebookModel, isTrusted: false });
|
||||
assert.deepEqual(model.attachments, contents.attachments, 'Attachments do not match in cellModel');
|
||||
assert.deepStrictEqual(model.attachments, contents.attachments, 'Attachments do not match in cellModel');
|
||||
|
||||
let serializedCell = model.toJSON();
|
||||
assert.deepEqual(serializedCell.attachments, cellAttachment, 'Cell attachment from JSON is incorrect');
|
||||
assert.deepStrictEqual(serializedCell.attachments, cellAttachment, 'Cell attachment from JSON is incorrect');
|
||||
});
|
||||
|
||||
test('Should not include attachments in notebook json if no attachments exist', async function () {
|
||||
@@ -1071,10 +1071,10 @@ suite('Cell Model', function (): void {
|
||||
source: ''
|
||||
};
|
||||
let model = factory.createCell(contents, { notebook: notebookModel, isTrusted: false });
|
||||
assert.deepEqual(model.attachments, undefined, 'Cell model attachments should return undefined if they do not exist');
|
||||
assert.deepStrictEqual(model.attachments, undefined, 'Cell model attachments should return undefined if they do not exist');
|
||||
|
||||
let serializedCell = model.toJSON();
|
||||
assert.deepEqual(serializedCell.attachments, undefined, 'JSON should not include attachments if attachments do not exist');
|
||||
assert.deepStrictEqual(serializedCell.attachments, undefined, 'JSON should not include attachments if attachments do not exist');
|
||||
});
|
||||
|
||||
test('Should not have cache chart data after new cell created', async function () {
|
||||
@@ -1088,7 +1088,7 @@ suite('Cell Model', function (): void {
|
||||
source: ''
|
||||
};
|
||||
let cellModel = factory.createCell(contents, { notebook: notebookModel, isTrusted: false }) as CellModel;
|
||||
assert.deepEqual(cellModel.previousChartState, [], 'New cell should have no previous chart state');
|
||||
assert.deepStrictEqual(cellModel.previousChartState, [], 'New cell should have no previous chart state');
|
||||
});
|
||||
|
||||
test('Should not cache chart data after clear output', async function () {
|
||||
@@ -1122,15 +1122,15 @@ suite('Cell Model', function (): void {
|
||||
|
||||
// When I create a cell
|
||||
let cellModel = factory.createCell(contents, { notebook: notebookModel, isTrusted: false }) as CellModel;
|
||||
assert.deepEqual(cellModel.previousChartState, [], 'New cell should have no previous chart state');
|
||||
assert.deepStrictEqual(cellModel.previousChartState, [], 'New cell should have no previous chart state');
|
||||
|
||||
// When previous chart state exists
|
||||
cellModel[<any>'_previousChartState'] = contents.outputs[0].metadata.azdata_chartOptions;
|
||||
assert.deepEqual(cellModel.previousChartState, contents.outputs[0].metadata.azdata_chartOptions, 'Previous chart state should be returned as is');
|
||||
assert.deepStrictEqual(cellModel.previousChartState, contents.outputs[0].metadata.azdata_chartOptions, 'Previous chart state should be returned as is');
|
||||
|
||||
// When cell outputs are cleared
|
||||
cellModel.clearOutputs();
|
||||
assert.deepEqual(cellModel.previousChartState, [], 'Previous chart state should be erased after clearing outputs');
|
||||
assert.deepStrictEqual(cellModel.previousChartState, [], 'Previous chart state should be erased after clearing outputs');
|
||||
|
||||
// Put previous chart state back
|
||||
cellModel[<any>'_previousChartState'] = contents.outputs[0].metadata.azdata_chartOptions;
|
||||
@@ -1141,7 +1141,7 @@ suite('Cell Model', function (): void {
|
||||
// When output is generated
|
||||
cellModel.setFuture(future.object);
|
||||
await onIopub.handle({ channel: 'iopub', content: { data: 'Hello' }, type: 'execute_reply', metadata: contents.outputs[0].metadata, header: { msg_type: 'execute_result' } });
|
||||
assert.deepEqual(cellModel.previousChartState, [], 'Previous chart state should not exist after cell source change');
|
||||
assert.deepStrictEqual(cellModel.previousChartState, [], 'Previous chart state should not exist after cell source change');
|
||||
|
||||
// Put previous chart state back
|
||||
cellModel[<any>'_previousChartState'] = contents.outputs[0].metadata.azdata_chartOptions;
|
||||
@@ -1149,7 +1149,7 @@ suite('Cell Model', function (): void {
|
||||
// When output is generated
|
||||
cellModel.setFuture(future.object);
|
||||
await onIopub.handle({ channel: 'iopub', content: { data: 'Hello' }, type: 'execute_reply', metadata: contents.outputs[0].metadata, header: { msg_type: 'execute_result' } });
|
||||
assert.deepEqual(cellModel.previousChartState, contents.outputs[0].metadata.azdata_chartOptions, 'Previous chart state should exist after output is generated');
|
||||
assert.deepStrictEqual(cellModel.previousChartState, contents.outputs[0].metadata.azdata_chartOptions, 'Previous chart state should exist after output is generated');
|
||||
});
|
||||
|
||||
test('Should read attachments from cell contents', async function () {
|
||||
@@ -1167,7 +1167,7 @@ suite('Cell Model', function (): void {
|
||||
attachments: attachments
|
||||
};
|
||||
let model = factory.createCell(contents, { notebook: notebookModel, isTrusted: false });
|
||||
assert.equal(model.attachments, attachments);
|
||||
assert.strictEqual(model.attachments, attachments);
|
||||
});
|
||||
|
||||
test('addAttachment should add a valid attachment to cell', async function () {
|
||||
@@ -1187,10 +1187,10 @@ suite('Cell Model', function (): void {
|
||||
};
|
||||
let model = factory.createCell(contents, { notebook: notebookModel, isTrusted: false });
|
||||
model.addAttachment('image/png', imageFilebase64Value, 'test.png');
|
||||
assert.deepEqual(model.attachments, attachments);
|
||||
assert.deepStrictEqual(model.attachments, attachments);
|
||||
attachments = { 'test.png': testImageAttachment, 'test1.png': testImageAttachment };
|
||||
model.addAttachment('image/png', imageFilebase64Value, 'test1.png');
|
||||
assert.deepEqual(model.attachments, attachments, 'addAttachment should add unique images');
|
||||
assert.deepStrictEqual(model.attachments, attachments, 'addAttachment should add unique images');
|
||||
});
|
||||
|
||||
test('addAttachment should not add an invalid attachment to cell', async function () {
|
||||
@@ -1207,7 +1207,7 @@ suite('Cell Model', function (): void {
|
||||
};
|
||||
let cellModel = factory.createCell(contents, { notebook: notebookModel, isTrusted: false });
|
||||
cellModel.addAttachment('image/png', imageFilebase64Value, 'test.png');
|
||||
assert.equal(cellModel.attachments, undefined);
|
||||
assert.strictEqual(cellModel.attachments, undefined);
|
||||
});
|
||||
|
||||
test('addAttachment should not add a duplicate attachment to cell', async function () {
|
||||
@@ -1227,8 +1227,8 @@ suite('Cell Model', function (): void {
|
||||
};
|
||||
let cellModel = factory.createCell(contents, { notebook: notebookModel, isTrusted: false });
|
||||
cellModel.addAttachment('image/png', imageFilebase64Value, 'test.png');
|
||||
assert.deepEqual(cellModel.attachments, attachments);
|
||||
assert.deepStrictEqual(cellModel.attachments, attachments);
|
||||
cellModel.addAttachment('image/png', imageFilebase64Value, 'test.png');
|
||||
assert.deepEqual(cellModel.attachments, attachments, 'addAttachment should not add duplicate images');
|
||||
assert.deepStrictEqual(cellModel.attachments, attachments, 'addAttachment should not add duplicate images');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -44,12 +44,12 @@ suite('Client Session', function (): void {
|
||||
});
|
||||
|
||||
test('Should set path, isReady and ready on construction', function (): void {
|
||||
assert.equal(session.notebookUri, path);
|
||||
assert.strictEqual(session.notebookUri, path);
|
||||
assert(!isUndefinedOrNull(session.ready));
|
||||
assert(!session.isReady);
|
||||
assert.equal(session.status, 'starting');
|
||||
assert.strictEqual(session.status, 'starting');
|
||||
assert(!session.isInErrorState);
|
||||
assert.equal(session.errorMessage, '');
|
||||
assert.strictEqual(session.errorMessage, '');
|
||||
});
|
||||
|
||||
test('Should call on serverManager startup if set', async function (): Promise<void> {
|
||||
@@ -79,7 +79,7 @@ suite('Client Session', function (): void {
|
||||
assert(session.isReady);
|
||||
assert(serverManager.calledStart);
|
||||
assert(session.isInErrorState);
|
||||
assert.equal(session.errorMessage, 'error');
|
||||
assert.strictEqual(session.errorMessage, 'error');
|
||||
});
|
||||
|
||||
test('Should be ready when session manager is ready', async function (): Promise<void> {
|
||||
@@ -130,7 +130,7 @@ suite('Client Session', function (): void {
|
||||
// Then
|
||||
assert(session.isReady);
|
||||
assert(session.isInErrorState);
|
||||
assert.equal(session.errorMessage, 'error');
|
||||
assert.strictEqual(session.errorMessage, 'error');
|
||||
});
|
||||
|
||||
test('Should start session automatically if kernel preference requests it', async function (): Promise<void> {
|
||||
@@ -145,10 +145,10 @@ suite('Client Session', function (): void {
|
||||
await session.initialize();
|
||||
|
||||
// Then
|
||||
assert.equal(session.isReady, true, 'Session is not ready');
|
||||
assert.equal(session.isInErrorState, false, 'Session should not be in error state');
|
||||
assert.equal(startOptions.kernelName, 'python', 'Session not started with python by default');
|
||||
assert.equal(startOptions.path, path.fsPath, 'Session start path is incorrect');
|
||||
assert.strictEqual(session.isReady, true, 'Session is not ready');
|
||||
assert.strictEqual(session.isInErrorState, false, 'Session should not be in error state');
|
||||
assert.strictEqual(startOptions.kernelName, 'python', 'Session not started with python by default');
|
||||
assert.strictEqual(startOptions.path, path.fsPath, 'Session start path is incorrect');
|
||||
});
|
||||
|
||||
test('Should shutdown session even if no serverManager is set', async function (): Promise<void> {
|
||||
|
||||
@@ -41,12 +41,12 @@ let expectedNotebookContent: nb.INotebookContents = {
|
||||
let notebookContentString = JSON.stringify(expectedNotebookContent);
|
||||
|
||||
function verifyMatchesExpectedNotebook(notebook: nb.INotebookContents): void {
|
||||
assert.equal(notebook.cells.length, 1, 'Expected 1 cell');
|
||||
assert.equal(notebook.cells[0].cell_type, CellTypes.Code);
|
||||
assert.equal(notebook.cells[0].source, expectedNotebookContent.cells[0].source);
|
||||
assert.equal(notebook.metadata.kernelspec.name, expectedNotebookContent.metadata.kernelspec.name);
|
||||
assert.equal(notebook.nbformat, expectedNotebookContent.nbformat);
|
||||
assert.equal(notebook.nbformat_minor, expectedNotebookContent.nbformat_minor);
|
||||
assert.strictEqual(notebook.cells.length, 1, 'Expected 1 cell');
|
||||
assert.strictEqual(notebook.cells[0].cell_type, CellTypes.Code);
|
||||
assert.strictEqual(notebook.cells[0].source, expectedNotebookContent.cells[0].source);
|
||||
assert.strictEqual(notebook.metadata.kernelspec.name, expectedNotebookContent.metadata.kernelspec.name);
|
||||
assert.strictEqual(notebook.nbformat, expectedNotebookContent.nbformat);
|
||||
assert.strictEqual(notebook.nbformat_minor, expectedNotebookContent.nbformat_minor);
|
||||
}
|
||||
|
||||
suite('Local Content Manager', function (): void {
|
||||
@@ -136,23 +136,23 @@ suite('Local Content Manager', function (): void {
|
||||
let notebook = await contentManager.getNotebookContents(URI.file(localFile));
|
||||
// then I expect output to have been normalized into a single string
|
||||
let displayOutput = <nb.IDisplayData>notebook.cells[0].outputs[0];
|
||||
assert.equal(displayOutput.data['text/html'], '<div></div>');
|
||||
assert.strictEqual(displayOutput.data['text/html'], '<div></div>');
|
||||
});
|
||||
|
||||
test('Should create a new empty notebook if content is undefined', async function (): Promise<void> {
|
||||
// verify that when loading content from an empty string, a new notebook is created.
|
||||
let content = await contentManager.loadFromContentString(undefined);
|
||||
assert.equal(content.metadata, undefined, 'Verify that metadata is undefined');
|
||||
assert.strictEqual(content.metadata, undefined, 'Verify that metadata is undefined');
|
||||
// verify that the notebook is empty
|
||||
assert.equal(content.cells.length, 0, 'Notebook should be empty, so the number of cells should be 0');
|
||||
assert.strictEqual(content.cells.length, 0, 'Notebook should be empty, so the number of cells should be 0');
|
||||
});
|
||||
|
||||
test('Should create a new empty notebook if content is an empty string', async function (): Promise<void> {
|
||||
// verify that when loading content from an empty string, a new notebook is created.
|
||||
let content = await contentManager.loadFromContentString('');
|
||||
assert.equal(content.metadata, undefined, 'Verify that metadata is undefined');
|
||||
assert.strictEqual(content.metadata, undefined, 'Verify that metadata is undefined');
|
||||
// verify that the notebook is empty
|
||||
assert.equal(content.cells.length, 0, 'Notebook should be empty, so the number of cells should be 0');
|
||||
assert.strictEqual(content.cells.length, 0, 'Notebook should be empty, so the number of cells should be 0');
|
||||
});
|
||||
|
||||
test('Should create a markdown cell', async function (): Promise<void> {
|
||||
@@ -176,9 +176,9 @@ suite('Local Content Manager', function (): void {
|
||||
let notebook = await contentManager.loadFromContentString(markdownNotebookContent);
|
||||
// assert that markdown cell is supported by
|
||||
// verifying the notebook matches the expectedNotebookMarkdownContent format
|
||||
assert.equal(notebook.cells.length, 1, 'The number of cells should be equal to 1');
|
||||
assert.equal(notebook.cells[0].cell_type, CellTypes.Markdown, 'The cell type should be markdown');
|
||||
assert.equal(notebook.cells[0].source, expectedNotebookMarkdownContent.cells[0].source, 'The content of the cell must match the expectedNotebookMarkdownContent');
|
||||
assert.strictEqual(notebook.cells.length, 1, 'The number of cells should be equal to 1');
|
||||
assert.strictEqual(notebook.cells[0].cell_type, CellTypes.Markdown, 'The cell type should be markdown');
|
||||
assert.strictEqual(notebook.cells[0].source, expectedNotebookMarkdownContent.cells[0].source, 'The content of the cell must match the expectedNotebookMarkdownContent');
|
||||
});
|
||||
|
||||
test('Should allow stream for output types', async function (): Promise<void> {
|
||||
@@ -208,7 +208,7 @@ suite('Local Content Manager', function (): void {
|
||||
let streamOutputContent = JSON.stringify(expectedNotebookStreamOutputContent);
|
||||
// Verify that the stream output type is supported
|
||||
let notebook = await contentManager.loadFromContentString(streamOutputContent);
|
||||
assert.equal(notebook.cells[0].outputs[0].output_type, 'stream', 'Cell output from notebook should be stream');
|
||||
assert.equal(notebook.cells[0].cell_type, expectedNotebookStreamOutputContent.cells[0].cell_type, 'Cell type of notebook should match the expectedNotebookStreamOutputContent');
|
||||
assert.strictEqual(notebook.cells[0].outputs[0].output_type, 'stream', 'Cell output from notebook should be stream');
|
||||
assert.strictEqual(notebook.cells[0].cell_type, expectedNotebookStreamOutputContent.cells[0].cell_type, 'Cell type of notebook should match the expectedNotebookStreamOutputContent');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -179,9 +179,9 @@ suite('Notebook Editor Model', function (): void {
|
||||
let notebookEditorModel = await createTextEditorModel(this);
|
||||
notebookEditorModel.replaceEntireTextEditorModel(notebookModel, undefined);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineCount(), 6);
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(5), ' "cells": []');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(2), ' "metadata": {},');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineCount(), 6);
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(5), ' "cells": []');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(2), ' "metadata": {},');
|
||||
});
|
||||
|
||||
test('should replace entire text model for add cell (0 -> 1 cells)', async function (): Promise<void> {
|
||||
@@ -200,11 +200,11 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
});
|
||||
@@ -224,7 +224,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
|
||||
newCell.executionCount = 1;
|
||||
contentChange = {
|
||||
@@ -235,11 +235,11 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellExecuted);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": 1');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": 1');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
@@ -251,7 +251,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
};
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellExecuted);
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": 10');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": 10');
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
newCell.executionCount = 15;
|
||||
@@ -262,7 +262,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
};
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellExecuted);
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": 15');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": 15');
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
newCell.executionCount = 105;
|
||||
@@ -273,7 +273,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
};
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellExecuted);
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": 105');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": 105');
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
});
|
||||
|
||||
@@ -292,7 +292,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
|
||||
contentChange = {
|
||||
changeType: NotebookChangeType.CellOutputCleared,
|
||||
@@ -302,11 +302,11 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellOutputCleared);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(15), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(15), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' }');
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
});
|
||||
@@ -326,7 +326,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
|
||||
contentChange = {
|
||||
changeType: NotebookChangeType.CellSourceUpdated,
|
||||
@@ -344,15 +344,15 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellSourceUpdated);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "This is a test\\n",');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' "Line 2 test\\n",');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(11), ' "Line 3 test"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(27), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(28), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "This is a test\\n",');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' "Line 2 test\\n",');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(11), ' "Line 3 test"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(27), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(28), ' }');
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
});
|
||||
@@ -372,7 +372,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
|
||||
contentChange = {
|
||||
changeType: NotebookChangeType.CellSourceUpdated,
|
||||
@@ -390,13 +390,13 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellSourceUpdated);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "This is a test"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "This is a test"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
});
|
||||
@@ -416,7 +416,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
|
||||
newCell.source = 'This is a test';
|
||||
|
||||
@@ -431,13 +431,13 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement, 'should not do a full replacement for a source update');
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "This is a test"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "This is a test"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
|
||||
});
|
||||
|
||||
@@ -456,7 +456,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
|
||||
newCell.source = 'This is a test' + os.EOL + 'Line 2 test' + os.EOL + 'Line 3 test';
|
||||
|
||||
@@ -471,15 +471,15 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement, 'should not do a full replacement for a source update');
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "This is a test\\n",');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' "Line 2 test\\n",');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(11), ' "Line 3 test"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(27), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(28), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "This is a test\\n",');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' "Line 2 test\\n",');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(11), ' "Line 3 test"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(27), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(28), ' }');
|
||||
});
|
||||
|
||||
test('should not replace entire text model for single line source change then delete', async function (): Promise<void> {
|
||||
@@ -497,10 +497,10 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' ""');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' ""');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
|
||||
contentChange = {
|
||||
changeType: NotebookChangeType.CellSourceUpdated,
|
||||
@@ -535,13 +535,13 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellSourceUpdated);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' ""');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' ""');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
});
|
||||
@@ -560,7 +560,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
};
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
|
||||
contentChange = {
|
||||
changeType: NotebookChangeType.CellSourceUpdated,
|
||||
@@ -579,12 +579,12 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellSourceUpdated);
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "This is a test\\n",');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' "Line 2 test\\n",');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(11), ' "Line 3 test"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "This is a test\\n",');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' "Line 2 test\\n",');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(11), ' "Line 3 test"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
|
||||
contentChange = {
|
||||
changeType: NotebookChangeType.CellSourceUpdated,
|
||||
@@ -603,10 +603,10 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellSourceUpdated);
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "Tt"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "Tt"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
});
|
||||
|
||||
test('should not replace entire text model and affect only edited cell', async function (): Promise<void> {
|
||||
@@ -651,16 +651,16 @@ suite('Notebook Editor Model', function (): void {
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8 + i * 21), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8 + i * 21), ' "source": [');
|
||||
if (i === 7) {
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9 + i * 21), ' "This is a test"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12 + i * 21), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9 + i * 21), ' "This is a test"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12 + i * 21), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
} else {
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9 + i * 21), ' ""');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9 + i * 21), ' ""');
|
||||
}
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10 + i * 21), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14 + i * 21), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25 + i * 21), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10 + i * 21), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14 + i * 21), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(25 + i * 21), ' "execution_count": null');
|
||||
assert(notebookEditorModel.editorModel.textEditorModel.getLineContent(26 + i * 21).startsWith(' }'));
|
||||
}
|
||||
});
|
||||
@@ -680,7 +680,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
|
||||
newCell[<any>'_outputs'] = newCell.outputs.concat(newCell.outputs);
|
||||
|
||||
@@ -691,14 +691,14 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellOutputUpdated);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(23), '}, {');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(31), '}');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(32), '],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(33), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(34), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(23), '}, {');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(31), '}');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(32), '],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(33), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(34), ' }');
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
});
|
||||
@@ -717,7 +717,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
|
||||
// First update the model with unmatched brackets
|
||||
let newUnmatchedBracketOutput: nb.IStreamResult = { output_type: 'stream', name: 'stdout', text: '[0em' };
|
||||
@@ -730,14 +730,14 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellOutputUpdated);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' "text": "[0em"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(27), '}');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(28), '],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(29), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(30), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' "text": "[0em"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(27), '}');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(28), '],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(29), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(30), ' }');
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
@@ -752,13 +752,13 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellOutputUpdated);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(32), ' "text": "test test test"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(33), ' }');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(34), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(35), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(36), ' }');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(37), ' ]');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(38), '}');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(32), ' "text": "test test test"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(33), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(34), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(35), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(36), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(37), ' ]');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(38), '}');
|
||||
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
});
|
||||
@@ -782,7 +782,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [],');
|
||||
|
||||
// add output
|
||||
newCell[<any>'_outputs'] = previousOutputs;
|
||||
@@ -794,12 +794,12 @@ suite('Notebook Editor Model', function (): void {
|
||||
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellOutputUpdated);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(23), '}');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(23), '}');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(25), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(26), ' }');
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
});
|
||||
@@ -813,7 +813,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
setupTextEditorModelWithEmptyOutputs(notebookEditorModel, newCell);
|
||||
|
||||
addTextToBeginningOfTextEditorModel(notebookEditorModel, newCell, '"This text is in quotes"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\"This text is in quotes\\""');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\"This text is in quotes\\""');
|
||||
|
||||
ensureStaticContentInOneLineCellIsCorrect(notebookEditorModel, newCell);
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
@@ -828,7 +828,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
setupTextEditorModelWithEmptyOutputs(notebookEditorModel, newCell);
|
||||
|
||||
addTextToBeginningOfTextEditorModel(notebookEditorModel, newCell, '""""""""""');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\"\\"\\"\\"\\"\\"\\"\\"\\"\\""');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\"\\"\\"\\"\\"\\"\\"\\"\\"\\""');
|
||||
|
||||
ensureStaticContentInOneLineCellIsCorrect(notebookEditorModel, newCell);
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
@@ -843,7 +843,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
setupTextEditorModelWithEmptyOutputs(notebookEditorModel, newCell);
|
||||
|
||||
addTextToBeginningOfTextEditorModel(notebookEditorModel, newCell, '\\\\\\\\\\');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\\\\\\\\\\\\\\\\\\\\"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\\\\\\\\\\\\\\\\\\\\"');
|
||||
|
||||
ensureStaticContentInOneLineCellIsCorrect(notebookEditorModel, newCell);
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
@@ -858,7 +858,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
setupTextEditorModelWithEmptyOutputs(notebookEditorModel, newCell);
|
||||
|
||||
addTextToBeginningOfTextEditorModel(notebookEditorModel, newCell, '\"\"\"\"\"\"\"\"\"\"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\""');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\""');
|
||||
|
||||
ensureStaticContentInOneLineCellIsCorrect(notebookEditorModel, newCell);
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
@@ -873,7 +873,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
setupTextEditorModelWithEmptyOutputs(notebookEditorModel, newCell);
|
||||
|
||||
addTextToBeginningOfTextEditorModel(notebookEditorModel, newCell, 'this is a long line in a cell test. Everything should serialize correctly! # Comments here: adding more tests is fun?');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "this is a long line in a cell test. Everything should serialize correctly! # Comments here: adding more tests is fun?"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "this is a long line in a cell test. Everything should serialize correctly! # Comments here: adding more tests is fun?"');
|
||||
|
||||
ensureStaticContentInOneLineCellIsCorrect(notebookEditorModel, newCell);
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
@@ -888,7 +888,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
setupTextEditorModelWithEmptyOutputs(notebookEditorModel, newCell);
|
||||
|
||||
addTextToBeginningOfTextEditorModel(notebookEditorModel, newCell, '`~1!2@3#4$5%6^7&8*9(0)-_=+[{]}\\|;:",<.>/?\'');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "`~1!2@3#4$5%6^7&8*9(0)-_=+[{]}\\\\|;:\\",<.>/?\'"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "`~1!2@3#4$5%6^7&8*9(0)-_=+[{]}\\\\|;:\\",<.>/?\'"');
|
||||
|
||||
ensureStaticContentInOneLineCellIsCorrect(notebookEditorModel, newCell);
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
@@ -903,7 +903,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
setupTextEditorModelWithEmptyOutputs(notebookEditorModel, newCell);
|
||||
|
||||
addTextToBeginningOfTextEditorModel(notebookEditorModel, newCell, '\'\'\'\'');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\'\'\'\'"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\'\'\'\'"');
|
||||
|
||||
ensureStaticContentInOneLineCellIsCorrect(notebookEditorModel, newCell);
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
@@ -918,7 +918,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
setupTextEditorModelWithEmptyOutputs(notebookEditorModel, newCell);
|
||||
|
||||
addTextToBeginningOfTextEditorModel(notebookEditorModel, newCell, '');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' ""');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' ""');
|
||||
|
||||
ensureStaticContentInOneLineCellIsCorrect(notebookEditorModel, newCell);
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
@@ -933,15 +933,15 @@ suite('Notebook Editor Model', function (): void {
|
||||
setupTextEditorModelWithEmptyOutputs(notebookEditorModel, newCell);
|
||||
|
||||
addTextToBeginningOfTextEditorModel(notebookEditorModel, newCell, '"test"' + os.EOL + 'test""');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\"test\\"\\n",');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\"test\\"\\n",');
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' "test\\"\\""');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(11), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(13), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(15), ' "outputs": [],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(17), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' "test\\"\\""');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(11), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(13), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(15), ' "outputs": [],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(17), ' }');
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
});
|
||||
@@ -955,15 +955,15 @@ suite('Notebook Editor Model', function (): void {
|
||||
setupTextEditorModelWithEmptyOutputs(notebookEditorModel, newCell);
|
||||
|
||||
addTextToBeginningOfTextEditorModel(notebookEditorModel, newCell, '"""""test"' + os.EOL + '"""""""test\\""');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\"\\"\\"\\"\\"test\\"\\n",');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(9), ' "\\"\\"\\"\\"\\"test\\"\\n",');
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' "\\"\\"\\"\\"\\"\\"\\"test\\\\\\"\\""');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(11), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(13), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(15), ' "outputs": [],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(17), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' "\\"\\"\\"\\"\\"\\"\\"test\\\\\\"\\""');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(11), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(13), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(15), ' "outputs": [],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(17), ' }');
|
||||
|
||||
assert(!notebookEditorModel.lastEditFullReplacement);
|
||||
});
|
||||
@@ -996,7 +996,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
notebookEditorModel.updateModel(contentChange, NotebookChangeType.CellsModified);
|
||||
assert(notebookEditorModel.lastEditFullReplacement);
|
||||
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [],');
|
||||
}
|
||||
|
||||
function addTextToBeginningOfTextEditorModel(notebookEditorModel: NotebookEditorModel, newCell: ICellModel, textToAdd: string) {
|
||||
@@ -1018,11 +1018,11 @@ suite('Notebook Editor Model', function (): void {
|
||||
}
|
||||
|
||||
function ensureStaticContentInOneLineCellIsCorrect(notebookEditorModel: NotebookEditorModel, newCell: ICellModel) {
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(15), ' "execution_count": null');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' }');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(8), ' "source": [');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(10), ' ],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(12), ' "azdata_cell_guid": "' + newCell.cellGuid + '"');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(14), ' "outputs": [],');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(15), ' "execution_count": null');
|
||||
assert.strictEqual(notebookEditorModel.editorModel.textEditorModel.getLineContent(16), ' }');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -119,15 +119,15 @@ suite('Notebook Find Model', function (): void {
|
||||
test('Should set notebook model on initialize', async function (): Promise<void> {
|
||||
//initialize find
|
||||
let notebookFindModel = new NotebookFindModel(model);
|
||||
assert.equal(notebookFindModel.notebookModel, model, 'Failed to set notebook model');
|
||||
assert.strictEqual(notebookFindModel.notebookModel, model, 'Failed to set notebook model');
|
||||
});
|
||||
|
||||
test('Should have no decorations on initialize', async function (): Promise<void> {
|
||||
//initialize find
|
||||
let notebookFindModel = new NotebookFindModel(model);
|
||||
assert.equal(notebookFindModel.findDecorations, undefined, 'findDecorations should be undefined on initialize');
|
||||
assert.equal(notebookFindModel.getPosition(), undefined, 'currentMatch should be undefined on initialize');
|
||||
assert.equal(notebookFindModel.getLastPosition(), undefined, 'previousMatch should be undefined on initialize');
|
||||
assert.strictEqual(notebookFindModel.findDecorations, undefined, 'findDecorations should be undefined on initialize');
|
||||
assert.strictEqual(notebookFindModel.getPosition(), undefined, 'currentMatch should be undefined on initialize');
|
||||
assert.strictEqual(notebookFindModel.getLastPosition(), undefined, 'previousMatch should be undefined on initialize');
|
||||
});
|
||||
|
||||
test('Should find results in the notebook', async function (): Promise<void> {
|
||||
@@ -139,9 +139,9 @@ suite('Notebook Find Model', function (): void {
|
||||
await notebookFindModel.find('markdown', false, false, max_find_count);
|
||||
|
||||
assert(notebookFindModel.findMatches, 'Find in notebook failed.');
|
||||
assert.equal(notebookFindModel.findMatches.length, 2, 'Find could not find all occurrences');
|
||||
assert.equal(notebookFindModel.findArray.length, 2, 'Find could not find all occurrences');
|
||||
assert.equal(notebookFindModel.getFindCount(), 2, 'Find count do not match find results');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 2, 'Find could not find all occurrences');
|
||||
assert.strictEqual(notebookFindModel.findArray.length, 2, 'Find could not find all occurrences');
|
||||
assert.strictEqual(notebookFindModel.getFindCount(), 2, 'Find count do not match find results');
|
||||
});
|
||||
|
||||
test('Should not find results in the notebook', async function (): Promise<void> {
|
||||
@@ -149,7 +149,7 @@ suite('Notebook Find Model', function (): void {
|
||||
let notebookFindModel = new NotebookFindModel(model);
|
||||
await notebookFindModel.find('notFound', false, false, max_find_count);
|
||||
|
||||
assert.equal(notebookFindModel.findMatches.length, 0, 'Find failed');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 0, 'Find failed');
|
||||
});
|
||||
|
||||
test('Should match find result ranges', async function (): Promise<void> {
|
||||
@@ -160,10 +160,10 @@ suite('Notebook Find Model', function (): void {
|
||||
await notebookFindModel.find('markdown', false, false, max_find_count);
|
||||
|
||||
let expectedFindRange1 = new NotebookRange(model.cells[0], 2, 13, 2, 21);
|
||||
assert.deepEqual(notebookFindModel.findMatches[0].range, expectedFindRange1, 'Find in markdown range is wrong :\n' + JSON.stringify(expectedFindRange1) + '\n ' + JSON.stringify(notebookFindModel.findMatches[0].range));
|
||||
assert.deepStrictEqual(notebookFindModel.findMatches[0].range, expectedFindRange1, 'Find in markdown range is wrong :\n' + JSON.stringify(expectedFindRange1) + '\n ' + JSON.stringify(notebookFindModel.findMatches[0].range));
|
||||
|
||||
let expectedFindRange2 = new NotebookRange(model.cells[1], 1, 6, 1, 14);
|
||||
assert.deepEqual(notebookFindModel.findMatches[1].range, expectedFindRange2, 'Find in markdown range is wrong :\n' + JSON.stringify(expectedFindRange2) + '\n ' + JSON.stringify(notebookFindModel.findMatches[1].range));
|
||||
assert.deepStrictEqual(notebookFindModel.findMatches[1].range, expectedFindRange2, 'Find in markdown range is wrong :\n' + JSON.stringify(expectedFindRange2) + '\n ' + JSON.stringify(notebookFindModel.findMatches[1].range));
|
||||
});
|
||||
|
||||
test('Should set selection when find matches results', async function (): Promise<void> {
|
||||
@@ -176,7 +176,7 @@ suite('Notebook Find Model', function (): void {
|
||||
|
||||
notebookFindModel.setSelection(notebookFindModel.findMatches[0].range);
|
||||
let expectedFindRange1 = new NotebookRange(model.cells[0], 2, 13, 2, 21);
|
||||
assert.deepEqual(notebookFindModel.currentMatch, expectedFindRange1, 'Find failed to set selection on finding results');
|
||||
assert.deepStrictEqual(notebookFindModel.currentMatch, expectedFindRange1, 'Find failed to set selection on finding results');
|
||||
});
|
||||
|
||||
test('Should ignore hyperlink markdown data and find correctly', async function (): Promise<void> {
|
||||
@@ -205,10 +205,10 @@ suite('Notebook Find Model', function (): void {
|
||||
let notebookFindModel = new NotebookFindModel(model);
|
||||
await notebookFindModel.find('best', false, false, max_find_count);
|
||||
|
||||
assert.equal(notebookFindModel.findMatches.length, 1, 'Find failed on markdown link');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 1, 'Find failed on markdown link');
|
||||
|
||||
let expectedFindRange1 = new NotebookRange(model.cells[0], 1, 21, 1, 25);
|
||||
assert.deepEqual(notebookFindModel.findMatches[0].range, expectedFindRange1, 'Find in markdown range is wrong :\n' + JSON.stringify(expectedFindRange1) + '\n ' + JSON.stringify(notebookFindModel.findMatches[0].range));
|
||||
assert.deepStrictEqual(notebookFindModel.findMatches[0].range, expectedFindRange1, 'Find in markdown range is wrong :\n' + JSON.stringify(expectedFindRange1) + '\n ' + JSON.stringify(notebookFindModel.findMatches[0].range));
|
||||
|
||||
});
|
||||
|
||||
@@ -235,7 +235,7 @@ suite('Notebook Find Model', function (): void {
|
||||
let notebookFindModel = new NotebookFindModel(model);
|
||||
await notebookFindModel.find('x', false, false, max_find_count);
|
||||
|
||||
assert.equal(notebookFindModel.findMatches.length, 3, 'Find failed');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 3, 'Find failed');
|
||||
});
|
||||
|
||||
test('Should match find results for multiple results on same line', async function (): Promise<void> {
|
||||
@@ -262,15 +262,15 @@ suite('Notebook Find Model', function (): void {
|
||||
// Intentionally not using max_find_count here, as 7 items should be found
|
||||
await notebookFindModel.find('abc', false, false, 10);
|
||||
|
||||
assert.equal(notebookFindModel.findMatches.length, 7, 'Find failed to find number of matches correctly');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 7, 'Find failed to find number of matches correctly');
|
||||
|
||||
assert.deepEqual(notebookFindModel.findMatches[0].range, new NotebookRange(model.cells[0], 1, 1, 1, 4));
|
||||
assert.deepEqual(notebookFindModel.findMatches[1].range, new NotebookRange(model.cells[0], 1, 5, 1, 8));
|
||||
assert.deepEqual(notebookFindModel.findMatches[2].range, new NotebookRange(model.cells[0], 1, 9, 1, 12));
|
||||
assert.deepEqual(notebookFindModel.findMatches[3].range, new NotebookRange(model.cells[0], 1, 13, 1, 16));
|
||||
assert.deepEqual(notebookFindModel.findMatches[4].range, new NotebookRange(model.cells[0], 1, 17, 1, 20));
|
||||
assert.deepEqual(notebookFindModel.findMatches[5].range, new NotebookRange(model.cells[0], 1, 21, 1, 24));
|
||||
assert.deepEqual(notebookFindModel.findMatches[6].range, new NotebookRange(model.cells[0], 1, 24, 1, 27));
|
||||
assert.deepStrictEqual(notebookFindModel.findMatches[0].range, new NotebookRange(model.cells[0], 1, 1, 1, 4));
|
||||
assert.deepStrictEqual(notebookFindModel.findMatches[1].range, new NotebookRange(model.cells[0], 1, 5, 1, 8));
|
||||
assert.deepStrictEqual(notebookFindModel.findMatches[2].range, new NotebookRange(model.cells[0], 1, 9, 1, 12));
|
||||
assert.deepStrictEqual(notebookFindModel.findMatches[3].range, new NotebookRange(model.cells[0], 1, 13, 1, 16));
|
||||
assert.deepStrictEqual(notebookFindModel.findMatches[4].range, new NotebookRange(model.cells[0], 1, 17, 1, 20));
|
||||
assert.deepStrictEqual(notebookFindModel.findMatches[5].range, new NotebookRange(model.cells[0], 1, 21, 1, 24));
|
||||
assert.deepStrictEqual(notebookFindModel.findMatches[6].range, new NotebookRange(model.cells[0], 1, 24, 1, 27));
|
||||
});
|
||||
|
||||
|
||||
@@ -283,10 +283,10 @@ suite('Notebook Find Model', function (): void {
|
||||
await notebookFindModel.find('insert', false, false, max_find_count);
|
||||
|
||||
assert(notebookFindModel.findMatches, 'Find in notebook failed.');
|
||||
assert.equal(notebookFindModel.findMatches.length, 3, 'Find couldn\'t find all occurrences');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 3, 'Find couldn\'t find all occurrences');
|
||||
|
||||
await notebookFindModel.find('insert', true, false, max_find_count);
|
||||
assert.equal(notebookFindModel.findMatches.length, 2, 'Find failed to apply match case while searching');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 2, 'Find failed to apply match case while searching');
|
||||
|
||||
});
|
||||
|
||||
@@ -295,7 +295,7 @@ suite('Notebook Find Model', function (): void {
|
||||
let notebookFindModel = new NotebookFindModel(model);
|
||||
|
||||
await notebookFindModel.find('insert', true, true, max_find_count);
|
||||
assert.equal(notebookFindModel.findMatches.length, 1, 'Find failed to apply whole word filter while searching');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 1, 'Find failed to apply whole word filter while searching');
|
||||
|
||||
});
|
||||
|
||||
@@ -322,14 +322,14 @@ suite('Notebook Find Model', function (): void {
|
||||
let notebookFindModel = new NotebookFindModel(model);
|
||||
// test for string with special character
|
||||
await notebookFindModel.find('{special}', true, true, max_find_count);
|
||||
assert.equal(notebookFindModel.findMatches.length, 1, 'Find failed for search term with special character');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 1, 'Find failed for search term with special character');
|
||||
// test for only special character !!
|
||||
await notebookFindModel.find('!!', false, false, max_find_count);
|
||||
assert.equal(notebookFindModel.findMatches.length, 2, 'Find failed for special character');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 2, 'Find failed for special character');
|
||||
|
||||
// test for only special character combination
|
||||
await notebookFindModel.find('!!!$}', false, false, max_find_count);
|
||||
assert.equal(notebookFindModel.findMatches.length, 1, 'Find failed for special character combination');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 1, 'Find failed for special character combination');
|
||||
});
|
||||
|
||||
test('Should find // characters in the search term correctly', async function (): Promise<void> {
|
||||
@@ -355,13 +355,13 @@ suite('Notebook Find Model', function (): void {
|
||||
let notebookFindModel = new NotebookFindModel(model);
|
||||
|
||||
await notebookFindModel.find('/', true, false, max_find_count);
|
||||
assert.equal(notebookFindModel.findMatches.length, 2, 'Find failed to find number of / occurrences');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 2, 'Find failed to find number of / occurrences');
|
||||
|
||||
await notebookFindModel.find('//', true, false, max_find_count);
|
||||
assert.equal(notebookFindModel.findMatches.length, 1, 'Find failed to find number of // occurrences');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 1, 'Find failed to find number of // occurrences');
|
||||
|
||||
await notebookFindModel.find('//', true, true, max_find_count);
|
||||
assert.equal(notebookFindModel.findMatches.length, 0, 'Find failed to apply match whole word for //');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 0, 'Find failed to apply match whole word for //');
|
||||
});
|
||||
|
||||
test('Should find results in the code cell on markdown edit', async function (): Promise<void> {
|
||||
@@ -390,14 +390,14 @@ suite('Notebook Find Model', function (): void {
|
||||
let notebookFindModel = new NotebookFindModel(model);
|
||||
await notebookFindModel.find('SOP', false, false, max_find_count);
|
||||
|
||||
assert.equal(notebookFindModel.findMatches.length, 1, 'Find failed on markdown');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 1, 'Find failed on markdown');
|
||||
|
||||
// fire the edit mode on cell
|
||||
model.cells[0].isEditMode = true;
|
||||
notebookFindModel = new NotebookFindModel(model);
|
||||
await notebookFindModel.find('SOP', false, false, max_find_count);
|
||||
|
||||
assert.equal(notebookFindModel.findMatches.length, 2, 'Find failed on markdown edit');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 2, 'Find failed on markdown edit');
|
||||
});
|
||||
|
||||
test('Find next/previous should return the correct find index', async function (): Promise<void> {
|
||||
@@ -408,13 +408,13 @@ suite('Notebook Find Model', function (): void {
|
||||
let notebookFindModel = new NotebookFindModel(model);
|
||||
await notebookFindModel.find('insert', false, false, max_find_count);
|
||||
|
||||
assert.equal(notebookFindModel.getFindIndex(), 1, 'Failed to get the correct find index');
|
||||
assert.strictEqual(notebookFindModel.getFindIndex(), 1, 'Failed to get the correct find index');
|
||||
|
||||
notebookFindModel.findNext();
|
||||
assert.equal(notebookFindModel.getFindIndex(), 2, 'Failed to get the correct find index');
|
||||
assert.strictEqual(notebookFindModel.getFindIndex(), 2, 'Failed to get the correct find index');
|
||||
|
||||
notebookFindModel.findPrevious();
|
||||
assert.equal(notebookFindModel.getFindIndex(), 1, 'Failed to get the correct find index');
|
||||
assert.strictEqual(notebookFindModel.getFindIndex(), 1, 'Failed to get the correct find index');
|
||||
});
|
||||
|
||||
test('Should clear results on clear', async function (): Promise<void> {
|
||||
@@ -425,11 +425,11 @@ suite('Notebook Find Model', function (): void {
|
||||
let notebookFindModel = new NotebookFindModel(model);
|
||||
await notebookFindModel.find('insert', false, false, max_find_count);
|
||||
|
||||
assert.equal(notebookFindModel.findMatches.length, 3, 'Failed to find all occurrences');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 3, 'Failed to find all occurrences');
|
||||
|
||||
notebookFindModel.clearFind();
|
||||
assert.equal(notebookFindModel.findMatches.length, 0, 'Failed to clear find results');
|
||||
assert.equal(notebookFindModel.findDecorations, undefined, 'Failed to clear find decorations on clear');
|
||||
assert.strictEqual(notebookFindModel.findMatches.length, 0, 'Failed to clear find results');
|
||||
assert.strictEqual(notebookFindModel.findDecorations, undefined, 'Failed to clear find decorations on clear');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ suite('notebook model', function (): void {
|
||||
await model.loadContents();
|
||||
|
||||
// Then I expect to have 0 code cell as the contents
|
||||
assert.equal(model.cells.length, 0);
|
||||
assert.strictEqual(model.cells.length, 0);
|
||||
|
||||
// And Trust should be true by default if there are no cells
|
||||
assert(model.trustedMode);
|
||||
@@ -238,9 +238,9 @@ suite('notebook model', function (): void {
|
||||
// When I initalize the model
|
||||
// Then it should throw
|
||||
let model = new NotebookModel(defaultModelOptions, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService);
|
||||
assert.equal(model.inErrorState, false);
|
||||
assert.strictEqual(model.inErrorState, false);
|
||||
await assert.rejects(async () => { await model.loadContents(); });
|
||||
assert.equal(model.inErrorState, true);
|
||||
assert.strictEqual(model.inErrorState, true);
|
||||
});
|
||||
|
||||
test('Should convert cell info to CellModels', async function (): Promise<void> {
|
||||
@@ -254,9 +254,9 @@ suite('notebook model', function (): void {
|
||||
await model.loadContents();
|
||||
|
||||
// Then I expect all cells to be in the model
|
||||
assert.equal(model.cells.length, 2);
|
||||
assert.deepEqual(model.cells[0].source, expectedNotebookContent.cells[0].source);
|
||||
assert.deepEqual(model.cells[1].source, expectedNotebookContent.cells[1].source);
|
||||
assert.strictEqual(model.cells.length, 2);
|
||||
assert.deepStrictEqual(model.cells[0].source, expectedNotebookContent.cells[0].source);
|
||||
assert.deepStrictEqual(model.cells[1].source, expectedNotebookContent.cells[1].source);
|
||||
});
|
||||
|
||||
test('Should handle multiple notebook managers', async function (): Promise<void> {
|
||||
@@ -282,7 +282,7 @@ suite('notebook model', function (): void {
|
||||
await model.loadContents();
|
||||
|
||||
// I expect the default provider to be jupyter
|
||||
assert.equal(model.notebookManager.providerId, 'jupyter', 'Notebook manager provider id incorrect');
|
||||
assert.strictEqual(model.notebookManager.providerId, 'jupyter', 'Notebook manager provider id incorrect');
|
||||
|
||||
// Similarly, change default notebook provider id to SQL
|
||||
defaultModelOptions.providerId = 'SQL';
|
||||
@@ -292,18 +292,18 @@ suite('notebook model', function (): void {
|
||||
await model.loadContents();
|
||||
|
||||
// I expect the default provider to be SQL
|
||||
assert.equal(model.notebookManager.providerId, 'SQL', 'Notebook manager provider id incorrect after 2nd model load');
|
||||
assert.strictEqual(model.notebookManager.providerId, 'SQL', 'Notebook manager provider id incorrect after 2nd model load');
|
||||
|
||||
// Check that the getters return the correct values
|
||||
assert.equal(model.notebookManagers.length, 2, 'There should be 2 notebook managers');
|
||||
assert.strictEqual(model.notebookManagers.length, 2, 'There should be 2 notebook managers');
|
||||
assert(!isUndefinedOrNull(model.getNotebookManager('SQL')), 'SQL notebook manager is not defined');
|
||||
assert(!isUndefinedOrNull(model.getNotebookManager('jupyter')), 'Jupyter notebook manager is not defined');
|
||||
assert(isUndefinedOrNull(model.getNotebookManager('foo')), 'foo notebook manager is incorrectly defined');
|
||||
|
||||
// Check other properties to ensure that they're returning as expected
|
||||
// No server manager was passed into the notebook manager stub, so expect hasServerManager to return false
|
||||
assert.equal(model.hasServerManager, false, 'Notebook model should not have a server manager');
|
||||
assert.equal(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.strictEqual(model.hasServerManager, false, 'Notebook model should not have a server manager');
|
||||
assert.strictEqual(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
});
|
||||
|
||||
test('Should set active cell correctly', async function (): Promise<void> {
|
||||
@@ -328,39 +328,39 @@ suite('notebook model', function (): void {
|
||||
model.contentChanged(c => notebookContentChange = c);
|
||||
|
||||
// Then I expect all cells to be in the model
|
||||
assert.equal(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
assert.strictEqual(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
|
||||
// Set the first cell as active
|
||||
model.updateActiveCell(model.cells[0]);
|
||||
assert.deepEqual(model.activeCell, model.cells[0], 'Active cell does not match the first cell');
|
||||
assert.deepEqual(model.activeCell, activeCellFromEvent, 'Active cell returned from the event does not match');
|
||||
assert.equal(activeCellChangeCount, 1, 'Active cell change count is incorrect');
|
||||
assert.deepStrictEqual(model.activeCell, model.cells[0], 'Active cell does not match the first cell');
|
||||
assert.deepStrictEqual(model.activeCell, activeCellFromEvent, 'Active cell returned from the event does not match');
|
||||
assert.strictEqual(activeCellChangeCount, 1, 'Active cell change count is incorrect');
|
||||
assert(isUndefinedOrNull(notebookContentChange), 'Content change should be undefined');
|
||||
|
||||
|
||||
// Set the second cell as active
|
||||
model.updateActiveCell(model.cells[1]);
|
||||
assert.deepEqual(model.activeCell, model.cells[1], 'Active cell does not match expected value');
|
||||
assert.deepEqual(model.activeCell, activeCellFromEvent, 'Active cell returned from the event does not match (2nd)');
|
||||
assert.equal(activeCellChangeCount, 2, 'Active cell change count is incorrect; should be 2');
|
||||
assert.deepStrictEqual(model.activeCell, model.cells[1], 'Active cell does not match expected value');
|
||||
assert.deepStrictEqual(model.activeCell, activeCellFromEvent, 'Active cell returned from the event does not match (2nd)');
|
||||
assert.strictEqual(activeCellChangeCount, 2, 'Active cell change count is incorrect; should be 2');
|
||||
|
||||
// Delete the active cell
|
||||
model.deleteCell(model.cells[1]);
|
||||
assert(isUndefinedOrNull(model.activeCell), 'Active cell should be undefined after active cell is deleted');
|
||||
assert.deepEqual(model.activeCell, activeCellFromEvent, 'Active cell should match value from event');
|
||||
assert.equal(activeCellChangeCount, 3, 'Active cell change count is incorrect; should be 3');
|
||||
assert.deepStrictEqual(model.activeCell, activeCellFromEvent, 'Active cell should match value from event');
|
||||
assert.strictEqual(activeCellChangeCount, 3, 'Active cell change count is incorrect; should be 3');
|
||||
|
||||
// Set the remaining cell as active
|
||||
model.updateActiveCell(model.cells[0]);
|
||||
assert.deepEqual(model.activeCell, activeCellFromEvent, 'Active cell should match value from event');
|
||||
assert.equal(activeCellChangeCount, 4, 'Active cell change count is incorrect; should be 4');
|
||||
assert.deepStrictEqual(model.activeCell, activeCellFromEvent, 'Active cell should match value from event');
|
||||
assert.strictEqual(activeCellChangeCount, 4, 'Active cell change count is incorrect; should be 4');
|
||||
|
||||
// Add new cell
|
||||
let newCell = model.addCell(CellTypes.Code, 0);
|
||||
|
||||
// Ensure new cell is active cell
|
||||
assert.deepEqual(model.activeCell, newCell, 'Active cell does not match newly created cell');
|
||||
assert.equal(activeCellChangeCount, 5, 'Active cell change count is incorrect; should be 5');
|
||||
assert.deepStrictEqual(model.activeCell, newCell, 'Active cell does not match newly created cell');
|
||||
assert.strictEqual(activeCellChangeCount, 5, 'Active cell change count is incorrect; should be 5');
|
||||
});
|
||||
|
||||
test('Should set notebook parameter and injected parameter cell correctly', async function (): Promise<void> {
|
||||
@@ -373,22 +373,22 @@ suite('notebook model', function (): void {
|
||||
let model = new NotebookModel(defaultModelOptions, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService);
|
||||
await model.loadContents();
|
||||
|
||||
assert.equal(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.equal(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
assert.strictEqual(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.strictEqual(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
|
||||
// Set parameter cell and injected parameters cell
|
||||
let notebookParamsCell = model.cells[0];
|
||||
let notebookInjectedParamsCell = model.cells[1];
|
||||
|
||||
// Parameters Cell Validation
|
||||
assert.equal(model.cells.indexOf(notebookParamsCell), 0, 'Notebook parameters cell should be first cell in notebook');
|
||||
assert.equal(notebookParamsCell.isParameter, true, 'Notebook parameters cell should be tagged parameter');
|
||||
assert.equal(notebookParamsCell.isInjectedParameter, false, 'Notebook parameters cell should not be tagged injected parameter');
|
||||
assert.strictEqual(model.cells.indexOf(notebookParamsCell), 0, 'Notebook parameters cell should be first cell in notebook');
|
||||
assert.strictEqual(notebookParamsCell.isParameter, true, 'Notebook parameters cell should be tagged parameter');
|
||||
assert.strictEqual(notebookParamsCell.isInjectedParameter, false, 'Notebook parameters cell should not be tagged injected parameter');
|
||||
|
||||
// Injected Parameters Cell Validation
|
||||
assert.equal(model.cells.indexOf(notebookInjectedParamsCell), 1, 'Notebook injected parameters cell should be second cell in notebook');
|
||||
assert.equal(notebookInjectedParamsCell.isParameter, false, 'Notebook injected parameters cell should not be tagged parameter cell');
|
||||
assert.equal(notebookInjectedParamsCell.isInjectedParameter, true, 'Notebook injected parameters cell should be tagged injected parameter');
|
||||
assert.strictEqual(model.cells.indexOf(notebookInjectedParamsCell), 1, 'Notebook injected parameters cell should be second cell in notebook');
|
||||
assert.strictEqual(notebookInjectedParamsCell.isParameter, false, 'Notebook injected parameters cell should not be tagged parameter cell');
|
||||
assert.strictEqual(notebookInjectedParamsCell.isInjectedParameter, true, 'Notebook injected parameters cell should be tagged injected parameter');
|
||||
});
|
||||
|
||||
test('Should set notebookUri parameters to new cell correctly', async function (): Promise<void> {
|
||||
@@ -401,14 +401,14 @@ suite('notebook model', function (): void {
|
||||
let model = new NotebookModel(defaultModelOptions, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService);
|
||||
await model.loadContents();
|
||||
|
||||
assert.equal(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.equal(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
assert.strictEqual(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.strictEqual(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
|
||||
// Validate notebookUri parameter cell is set as the only parameter cell
|
||||
let notebookUriParamsCell = model.cells[0];
|
||||
assert.equal(model.cells.indexOf(notebookUriParamsCell), 0, 'NotebookURI parameters cell should be first cell in notebook');
|
||||
assert.equal(notebookUriParamsCell.isParameter, true, 'NotebookURI parameters cell should be tagged parameter');
|
||||
assert.equal(notebookUriParamsCell.isInjectedParameter, false, 'NotebookURI parameters Cell should not be injected parameter');
|
||||
assert.strictEqual(model.cells.indexOf(notebookUriParamsCell), 0, 'NotebookURI parameters cell should be first cell in notebook');
|
||||
assert.strictEqual(notebookUriParamsCell.isParameter, true, 'NotebookURI parameters cell should be tagged parameter');
|
||||
assert.strictEqual(notebookUriParamsCell.isInjectedParameter, false, 'NotebookURI parameters Cell should not be injected parameter');
|
||||
});
|
||||
|
||||
test('Should set notebookUri parameters to new cell after parameters cell correctly', async function (): Promise<void> {
|
||||
@@ -425,14 +425,14 @@ suite('notebook model', function (): void {
|
||||
let model = new NotebookModel(defaultModelOptions, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService);
|
||||
await model.loadContents();
|
||||
|
||||
assert.equal(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.equal(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
assert.strictEqual(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.strictEqual(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
|
||||
// Validate notebookUri parameter cell is set as injected parameter
|
||||
let notebookUriParamsCell = model.cells[1];
|
||||
assert.equal(model.cells.indexOf(notebookUriParamsCell), 1, 'NotebookURI parameters cell should be second cell in notebook');
|
||||
assert.equal(notebookUriParamsCell.isParameter, false, 'NotebookURI parameters cell should not be tagged parameter cell');
|
||||
assert.equal(notebookUriParamsCell.isInjectedParameter, true, 'NotebookURI parameters Cell should be injected parameter');
|
||||
assert.strictEqual(model.cells.indexOf(notebookUriParamsCell), 1, 'NotebookURI parameters cell should be second cell in notebook');
|
||||
assert.strictEqual(notebookUriParamsCell.isParameter, false, 'NotebookURI parameters cell should not be tagged parameter cell');
|
||||
assert.strictEqual(notebookUriParamsCell.isInjectedParameter, true, 'NotebookURI parameters Cell should be injected parameter');
|
||||
});
|
||||
|
||||
test('Should set notebookUri parameters to new cell after injected parameters cell correctly', async function (): Promise<void> {
|
||||
@@ -446,14 +446,14 @@ suite('notebook model', function (): void {
|
||||
let model = new NotebookModel(defaultModelOptions, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService);
|
||||
await model.loadContents();
|
||||
|
||||
assert.equal(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.equal(model.cells.length, 3, 'Cell count in notebook model is not correct');
|
||||
assert.strictEqual(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.strictEqual(model.cells.length, 3, 'Cell count in notebook model is not correct');
|
||||
|
||||
// Validate notebookUri parameter cell is set as an injected parameter after parameter and injected parameter cells
|
||||
let notebookUriParamsCell = model.cells[2];
|
||||
assert.equal(model.cells.indexOf(notebookUriParamsCell), 2, 'NotebookURI parameters cell should be third cell in notebook');
|
||||
assert.equal(notebookUriParamsCell.isParameter, false, 'NotebookURI parameters cell should not be tagged parameter cell');
|
||||
assert.equal(notebookUriParamsCell.isInjectedParameter, true, 'NotebookURI parameters Cell should be injected parameter');
|
||||
assert.strictEqual(model.cells.indexOf(notebookUriParamsCell), 2, 'NotebookURI parameters cell should be third cell in notebook');
|
||||
assert.strictEqual(notebookUriParamsCell.isParameter, false, 'NotebookURI parameters cell should not be tagged parameter cell');
|
||||
assert.strictEqual(notebookUriParamsCell.isInjectedParameter, true, 'NotebookURI parameters Cell should be injected parameter');
|
||||
});
|
||||
|
||||
test('Should move first cell below second cell correctly', async function (): Promise<void> {
|
||||
@@ -465,15 +465,15 @@ suite('notebook model', function (): void {
|
||||
let model = new NotebookModel(defaultModelOptions, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService);
|
||||
await model.loadContents();
|
||||
|
||||
assert.equal(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.equal(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
assert.strictEqual(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.strictEqual(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
|
||||
let firstCell = model.cells[0];
|
||||
let secondCell = model.cells[1];
|
||||
// Move First Cell down
|
||||
model.moveCell(firstCell, 1);
|
||||
assert.equal(model.cells.indexOf(firstCell), 1, 'First Cell did not move down correctly');
|
||||
assert.equal(model.cells.indexOf(secondCell), 0, 'Second Cell did not move up correctly');
|
||||
assert.strictEqual(model.cells.indexOf(firstCell), 1, 'First Cell did not move down correctly');
|
||||
assert.strictEqual(model.cells.indexOf(secondCell), 0, 'Second Cell did not move up correctly');
|
||||
});
|
||||
|
||||
test('Should move second cell up above the first cell correctly', async function (): Promise<void> {
|
||||
@@ -485,15 +485,15 @@ suite('notebook model', function (): void {
|
||||
let model = new NotebookModel(defaultModelOptions, undefined, logService, undefined, new NullAdsTelemetryService(), queryConnectionService.object, configurationService);
|
||||
await model.loadContents();
|
||||
|
||||
assert.equal(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.equal(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
assert.strictEqual(model.notebookUri, defaultModelOptions.notebookUri, 'Notebook model has incorrect URI');
|
||||
assert.strictEqual(model.cells.length, 2, 'Cell count in notebook model is not correct');
|
||||
|
||||
let firstCell = model.cells[0];
|
||||
let secondCell = model.cells[1];
|
||||
// Move Second Cell up
|
||||
model.moveCell(secondCell, 0);
|
||||
assert.equal(model.cells.indexOf(firstCell), 1, 'First Cell did not move down correctly');
|
||||
assert.equal(model.cells.indexOf(secondCell), 0, 'Second Cell did not move up correctly');
|
||||
assert.strictEqual(model.cells.indexOf(firstCell), 1, 'First Cell did not move down correctly');
|
||||
assert.strictEqual(model.cells.indexOf(secondCell), 0, 'Second Cell did not move up correctly');
|
||||
});
|
||||
|
||||
test('Should delete cells correctly', async function (): Promise<void> {
|
||||
@@ -513,38 +513,38 @@ suite('notebook model', function (): void {
|
||||
model.contentChanged(c => notebookContentChange = c);
|
||||
|
||||
// Then I expect all cells to be in the model
|
||||
assert.equal(model.cells.length, 2, 'Cell count in model is incorrect');
|
||||
assert.strictEqual(model.cells.length, 2, 'Cell count in model is incorrect');
|
||||
|
||||
assert.equal(model.findCellIndex(model.cells[0]), 0, 'findCellIndex returned wrong cell info for first cell');
|
||||
assert.equal(model.findCellIndex(model.cells[1]), 1, 'findCellIndex returned wrong cell info for second cell');
|
||||
assert.strictEqual(model.findCellIndex(model.cells[0]), 0, 'findCellIndex returned wrong cell info for first cell');
|
||||
assert.strictEqual(model.findCellIndex(model.cells[1]), 1, 'findCellIndex returned wrong cell info for second cell');
|
||||
// Delete the first cell
|
||||
model.deleteCell(model.cells[0]);
|
||||
assert.equal(model.cells.length, 1, 'Cell model length should be 1 after cell deletion');
|
||||
assert.deepEqual(model.cells[0].source, expectedNotebookContent.cells[1].source, 'Expected cell source is incorrect');
|
||||
assert.equal(model.findCellIndex(model.cells[0]), 0, 'findCellIndex returned wrong cell info for only remaining cell');
|
||||
assert.equal(notebookContentChange.changeType, NotebookChangeType.CellsModified, 'notebookContentChange changeType is incorrect');
|
||||
assert.equal(notebookContentChange.isDirty, true, 'notebookContentChange should set dirty flag');
|
||||
assert.equal(model.activeCell, undefined, 'active cell is not undefined');
|
||||
assert.strictEqual(model.cells.length, 1, 'Cell model length should be 1 after cell deletion');
|
||||
assert.deepStrictEqual(model.cells[0].source, expectedNotebookContent.cells[1].source, 'Expected cell source is incorrect');
|
||||
assert.strictEqual(model.findCellIndex(model.cells[0]), 0, 'findCellIndex returned wrong cell info for only remaining cell');
|
||||
assert.strictEqual(notebookContentChange.changeType, NotebookChangeType.CellsModified, 'notebookContentChange changeType is incorrect');
|
||||
assert.strictEqual(notebookContentChange.isDirty, true, 'notebookContentChange should set dirty flag');
|
||||
assert.strictEqual(model.activeCell, undefined, 'active cell is not undefined');
|
||||
|
||||
// Delete the remaining cell
|
||||
notebookContentChange = undefined;
|
||||
model.deleteCell(model.cells[0]);
|
||||
assert.equal(model.cells.length, 0, 'There should be no cells tracked in the notebook model');
|
||||
assert.equal(model.findCellIndex(model.cells[0]), -1, 'findCellIndex is incorrectly finding a deleted cell');
|
||||
assert.equal(errorCount, 0, 'There should be no errors after deleting a cell that exists');
|
||||
assert.equal(notebookContentChange.changeType, NotebookChangeType.CellsModified, 'notebookContentChange changeType should indicate CellsModified');
|
||||
assert.equal(model.activeCell, undefined, 'Active cell should be undefined');
|
||||
assert.strictEqual(model.cells.length, 0, 'There should be no cells tracked in the notebook model');
|
||||
assert.strictEqual(model.findCellIndex(model.cells[0]), -1, 'findCellIndex is incorrectly finding a deleted cell');
|
||||
assert.strictEqual(errorCount, 0, 'There should be no errors after deleting a cell that exists');
|
||||
assert.strictEqual(notebookContentChange.changeType, NotebookChangeType.CellsModified, 'notebookContentChange changeType should indicate CellsModified');
|
||||
assert.strictEqual(model.activeCell, undefined, 'Active cell should be undefined');
|
||||
|
||||
// Try deleting the cell again
|
||||
notebookContentChange = undefined;
|
||||
model.deleteCell(model.cells[0]);
|
||||
assert.equal(errorCount, 1, 'The model should record an error after trying to delete a cell that does not exist');
|
||||
assert.strictEqual(errorCount, 1, 'The model should record an error after trying to delete a cell that does not exist');
|
||||
assert(isUndefinedOrNull(notebookContentChange), 'There should be no content change after an error is recorded');
|
||||
|
||||
// Try deleting as notebook model is in error state
|
||||
notebookContentChange = undefined;
|
||||
model.deleteCell(model.cells[0]);
|
||||
assert.equal(errorCount, 2, 'Error count should be 2 after trying to delete a cell that does not exist a second time');
|
||||
assert.strictEqual(errorCount, 2, 'Error count should be 2 after trying to delete a cell that does not exist a second time');
|
||||
assert(isUndefinedOrNull(notebookContentChange), 'There still should be no content change after an error is recorded');
|
||||
});
|
||||
|
||||
@@ -562,7 +562,7 @@ suite('notebook model', function (): void {
|
||||
|
||||
model.cells[0].metadata = { 'test-field': 'test-value' };
|
||||
assert(!isUndefinedOrNull(notebookContentChange));
|
||||
assert.equal(notebookContentChange.changeType, NotebookChangeType.CellMetadataUpdated, 'notebookContentChange changeType should indicate ');
|
||||
assert.strictEqual(notebookContentChange.changeType, NotebookChangeType.CellMetadataUpdated, 'notebookContentChange changeType should indicate ');
|
||||
});
|
||||
|
||||
test('Should set cell language correctly after cell type conversion', async function (): Promise<void> {
|
||||
@@ -579,18 +579,18 @@ suite('notebook model', function (): void {
|
||||
let firstCell = model.cells[0];
|
||||
let secondCell = model.cells[1];
|
||||
|
||||
assert.equal(firstCell.cellType, CellTypes.Code, 'Initial cell type for first cell should be code');
|
||||
assert.equal(firstCell.language, 'sql', 'Initial language should be sql for first cell');
|
||||
assert.strictEqual(firstCell.cellType, CellTypes.Code, 'Initial cell type for first cell should be code');
|
||||
assert.strictEqual(firstCell.language, 'sql', 'Initial language should be sql for first cell');
|
||||
|
||||
model.convertCellType(firstCell);
|
||||
assert.equal(firstCell.cellType, CellTypes.Markdown, 'Failed to convert cell type after conversion');
|
||||
assert.equal(firstCell.language, 'markdown', 'Language should be markdown for text cells');
|
||||
assert.deepEqual(newCell, firstCell);
|
||||
assert.strictEqual(firstCell.cellType, CellTypes.Markdown, 'Failed to convert cell type after conversion');
|
||||
assert.strictEqual(firstCell.language, 'markdown', 'Language should be markdown for text cells');
|
||||
assert.deepStrictEqual(newCell, firstCell);
|
||||
|
||||
model.convertCellType(secondCell);
|
||||
assert.equal(secondCell.cellType, CellTypes.Code, 'Failed to convert second cell type');
|
||||
assert.equal(secondCell.language, 'sql', 'Language should be sql again for second cell');
|
||||
assert.deepEqual(newCell, secondCell);
|
||||
assert.strictEqual(secondCell.cellType, CellTypes.Code, 'Failed to convert second cell type');
|
||||
assert.strictEqual(secondCell.language, 'sql', 'Language should be sql again for second cell');
|
||||
assert.deepStrictEqual(newCell, secondCell);
|
||||
});
|
||||
|
||||
test('Should load contents but then go to error state if client session startup fails', async function (): Promise<void> {
|
||||
@@ -610,21 +610,21 @@ suite('notebook model', function (): void {
|
||||
// Cannot set property 'defaultKernelLoaded' of undefined
|
||||
await assert.rejects(async () => { await model.startSession(notebookManagers[0]); });
|
||||
// Then I expect load to succeed
|
||||
assert.equal(model.cells.length, 1);
|
||||
assert.strictEqual(model.cells.length, 1);
|
||||
assert(model.clientSession);
|
||||
// but on server load completion I expect error state to be set
|
||||
// Note: do not expect serverLoad event to throw even if failed
|
||||
await model.sessionLoadFinished;
|
||||
assert.equal(model.inErrorState, false);
|
||||
assert.equal(sessionFired, false);
|
||||
assert.strictEqual(model.inErrorState, false);
|
||||
assert.strictEqual(sessionFired, false);
|
||||
});
|
||||
|
||||
test('Should not be in error state if client session initialization succeeds', async function (): Promise<void> {
|
||||
let model = await loadModelAndStartClientSession(expectedNotebookContent);
|
||||
|
||||
assert.equal(model.inErrorState, false);
|
||||
assert.equal(model.notebookManagers.length, 1);
|
||||
assert.deepEqual(model.clientSession, mockClientSession);
|
||||
assert.strictEqual(model.inErrorState, false);
|
||||
assert.strictEqual(model.notebookManagers.length, 1);
|
||||
assert.deepStrictEqual(model.clientSession, mockClientSession);
|
||||
});
|
||||
|
||||
test('Should notify on trust set', async function () {
|
||||
@@ -643,7 +643,7 @@ suite('notebook model', function (): void {
|
||||
// Then content changed notification should be sent
|
||||
assert(model.trustedMode);
|
||||
assert(!isUndefinedOrNull(actualChanged));
|
||||
assert.equal(actualChanged.changeType, NotebookChangeType.TrustChanged);
|
||||
assert.strictEqual(actualChanged.changeType, NotebookChangeType.TrustChanged);
|
||||
});
|
||||
|
||||
test('Should close active session when closed', async function () {
|
||||
@@ -656,7 +656,7 @@ suite('notebook model', function (): void {
|
||||
// Ensure client session is cleaned up
|
||||
assert(isUndefinedOrNull(model.clientSession), 'clientSession is not cleaned up properly');
|
||||
// Ensure session is no longer ready
|
||||
assert.equal(model.isSessionReady, false, 'session is incorrectly showing as ready');
|
||||
assert.strictEqual(model.isSessionReady, false, 'session is incorrectly showing as ready');
|
||||
});
|
||||
|
||||
test('Should disconnect when connection profile created by notebook', async function () {
|
||||
@@ -722,7 +722,7 @@ suite('notebook model', function (): void {
|
||||
let expectedAlias = ['fakeAlias'];
|
||||
let kernelAliases = model.kernelAliases;
|
||||
|
||||
assert.equal(kernelAliases.length, 1);
|
||||
assert.strictEqual(kernelAliases.length, 1);
|
||||
assert(kernelAliases.includes(expectedAlias[0]));
|
||||
|
||||
// // After client session is started, ensure context isn't null/undefined
|
||||
@@ -748,8 +748,8 @@ suite('notebook model', function (): void {
|
||||
let doChangeKernelStub = sinon.spy(model, 'doChangeKernel' as keyof NotebookModel);
|
||||
|
||||
model.changeKernel(notebookKernelAlias);
|
||||
assert.equal(model.selectedKernelDisplayName, notebookKernelAlias);
|
||||
assert.equal(model.currentKernelAlias, notebookKernelAlias);
|
||||
assert.strictEqual(model.selectedKernelDisplayName, notebookKernelAlias);
|
||||
assert.strictEqual(model.currentKernelAlias, notebookKernelAlias);
|
||||
sinon.assert.calledWith(doChangeKernelStub, model.kernelAliases[0]);
|
||||
doChangeKernelStub.restore();
|
||||
|
||||
@@ -776,8 +776,8 @@ suite('notebook model', function (): void {
|
||||
|
||||
// Change kernel first to alias kernel and then connect to SQL connection
|
||||
model.changeKernel(notebookKernelAlias);
|
||||
assert.equal(model.selectedKernelDisplayName, notebookKernelAlias);
|
||||
assert.equal(model.currentKernelAlias, notebookKernelAlias);
|
||||
assert.strictEqual(model.selectedKernelDisplayName, notebookKernelAlias);
|
||||
assert.strictEqual(model.currentKernelAlias, notebookKernelAlias);
|
||||
sinon.assert.called(doChangeKernelStub);
|
||||
doChangeKernelStub.restore();
|
||||
|
||||
@@ -785,8 +785,8 @@ suite('notebook model', function (): void {
|
||||
await changeContextWithConnectionProfile(model);
|
||||
let expectedKernel = 'SQL';
|
||||
model.changeKernel(expectedKernel);
|
||||
assert.equal(model.selectedKernelDisplayName, expectedKernel);
|
||||
assert.equal(model.currentKernelAlias, undefined);
|
||||
assert.strictEqual(model.selectedKernelDisplayName, expectedKernel);
|
||||
assert.strictEqual(model.currentKernelAlias, undefined);
|
||||
sinon.assert.called(doChangeKernelStub);
|
||||
doChangeKernelStub.restore();
|
||||
|
||||
@@ -838,7 +838,7 @@ suite('notebook model', function (): void {
|
||||
await model.loadContents();
|
||||
|
||||
// I expect the saved connection name to be read
|
||||
assert.equal(model.savedConnectionName, connectionName);
|
||||
assert.strictEqual(model.savedConnectionName, connectionName);
|
||||
|
||||
// When I request a connection
|
||||
let spy = sinon.stub(model, 'changeContext').returns(Promise.resolve());
|
||||
@@ -867,21 +867,21 @@ suite('notebook model', function (): void {
|
||||
await model.loadContents();
|
||||
|
||||
// I expect multiConnectionMode to be set to true
|
||||
assert.equal(model.multiConnectionMode, true, 'multi_connection_mode not read correctly from notebook metadata');
|
||||
assert.strictEqual(model.multiConnectionMode, true, 'multi_connection_mode not read correctly from notebook metadata');
|
||||
|
||||
// When I change multiConnectionMode to false
|
||||
model.multiConnectionMode = false;
|
||||
|
||||
// I expect multi_connection_mode to not be in the notebook metadata
|
||||
let output: nb.INotebookContents = model.toJSON();
|
||||
assert.equal(output.metadata['multi_connection_mode'], undefined, 'multi_connection_mode saved in notebook metadata when it should not be');
|
||||
assert.strictEqual(output.metadata['multi_connection_mode'], undefined, 'multi_connection_mode saved in notebook metadata when it should not be');
|
||||
|
||||
// When I change multiConnectionMode to true
|
||||
model.multiConnectionMode = true;
|
||||
|
||||
// I expect multi_connection_mode to be in the notebook metadata
|
||||
output = model.toJSON();
|
||||
assert.equal(output.metadata['multi_connection_mode'], true, 'multi_connection_mode not saved correctly to notebook metadata');
|
||||
assert.strictEqual(output.metadata['multi_connection_mode'], true, 'multi_connection_mode not saved correctly to notebook metadata');
|
||||
});
|
||||
|
||||
test('Should keep kernel alias as language info kernel alias name even if kernel spec is seralized as SQL', async function () {
|
||||
@@ -900,7 +900,7 @@ suite('notebook model', function (): void {
|
||||
await model.requestModelLoad();
|
||||
|
||||
// Check to see if language info is set to kernel alias
|
||||
assert.equal(model.languageInfo.name, 'fake', 'Notebook language info is not set properly');
|
||||
assert.strictEqual(model.languageInfo.name, 'fake', 'Notebook language info is not set properly');
|
||||
});
|
||||
|
||||
async function loadModelAndStartClientSession(notebookContent: nb.INotebookContents): Promise<NotebookModel> {
|
||||
@@ -926,7 +926,7 @@ suite('notebook model', function (): void {
|
||||
// Then I expect load to succeed
|
||||
assert(!isUndefinedOrNull(model.clientSession), 'clientSession should exist after session is started');
|
||||
|
||||
assert.deepEqual(actualSession, mockClientSession, 'session returned is not the expected object');
|
||||
assert.deepStrictEqual(actualSession, mockClientSession, 'session returned is not the expected object');
|
||||
|
||||
// but on server load completion I expect error state to be set
|
||||
// Note: do not expect serverLoad event to throw even if failed
|
||||
|
||||
@@ -151,20 +151,20 @@ suite('notebookUtils', function (): void {
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magic command', 'magic');
|
||||
assert.equal(result.commandId, 'command');
|
||||
assert.equal(result.args, '');
|
||||
assert.strictEqual(result.commandId, 'command');
|
||||
assert.strictEqual(result.args, '');
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magic command arg1', 'magic');
|
||||
assert.equal(result.commandId, 'command');
|
||||
assert.equal(result.args, 'arg1');
|
||||
assert.strictEqual(result.commandId, 'command');
|
||||
assert.strictEqual(result.args, 'arg1');
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magic command arg1 arg2', 'magic');
|
||||
assert.equal(result.commandId, 'command');
|
||||
assert.equal(result.args, 'arg1 arg2');
|
||||
assert.strictEqual(result.commandId, 'command');
|
||||
assert.strictEqual(result.args, 'arg1 arg2');
|
||||
|
||||
result = extractCellMagicCommandPlusArgs('%%magic command.id arg1 arg2 arg3', 'magic');
|
||||
assert.equal(result.commandId, 'command.id');
|
||||
assert.equal(result.args, 'arg1 arg2 arg3');
|
||||
assert.strictEqual(result.commandId, 'command.id');
|
||||
assert.strictEqual(result.args, 'arg1 arg2 arg3');
|
||||
});
|
||||
|
||||
test('asyncForEach Test', async function (): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user