strictEqual
This commit is contained in:
Родитель
d5aef4b631
Коммит
d641e3a5ce
|
@ -6,107 +6,107 @@ import { rawToNotebookCellData } from '../../extension';
|
|||
suite('parseMarkdown', () => {
|
||||
test('markdown cell', () => {
|
||||
const cells = parseMarkdown('# hello');
|
||||
assert.equal(cells.length, 1);
|
||||
assert.equal(cells[0].content, '# hello');
|
||||
assert.equal(cells[0].leadingWhitespace, '');
|
||||
assert.equal(cells[0].trailingWhitespace, '');
|
||||
assert.strictEqual(cells.length, 1);
|
||||
assert.strictEqual(cells[0].content, '# hello');
|
||||
assert.strictEqual(cells[0].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[0].trailingWhitespace, '');
|
||||
});
|
||||
|
||||
test('markdown cell, w/ whitespace', () => {
|
||||
const cells = parseMarkdown('\n\n# hello\n');
|
||||
assert.equal(cells.length, 1);
|
||||
assert.equal(cells[0].content, '# hello');
|
||||
assert.equal(cells[0].leadingWhitespace, '\n\n');
|
||||
assert.equal(cells[0].trailingWhitespace, '\n');
|
||||
assert.strictEqual(cells.length, 1);
|
||||
assert.strictEqual(cells[0].content, '# hello');
|
||||
assert.strictEqual(cells[0].leadingWhitespace, '\n\n');
|
||||
assert.strictEqual(cells[0].trailingWhitespace, '\n');
|
||||
});
|
||||
|
||||
test('2 markdown cells', () => {
|
||||
const cells = parseMarkdown('# hello\n\n# goodbye\n');
|
||||
assert.equal(cells.length, 2);
|
||||
assert.equal(cells[0].content, '# hello');
|
||||
assert.equal(cells[0].leadingWhitespace, '');
|
||||
assert.equal(cells[0].trailingWhitespace, '\n\n');
|
||||
assert.strictEqual(cells.length, 2);
|
||||
assert.strictEqual(cells[0].content, '# hello');
|
||||
assert.strictEqual(cells[0].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[0].trailingWhitespace, '\n\n');
|
||||
|
||||
assert.equal(cells[1].content, '# goodbye');
|
||||
assert.equal(cells[1].leadingWhitespace, '');
|
||||
assert.equal(cells[1].trailingWhitespace, '\n');
|
||||
assert.strictEqual(cells[1].content, '# goodbye');
|
||||
assert.strictEqual(cells[1].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[1].trailingWhitespace, '\n');
|
||||
});
|
||||
|
||||
test('code cell', () => {
|
||||
const cells = parseMarkdown('```js\nlet x = 1;\n```');
|
||||
assert.equal(cells.length, 1);
|
||||
assert.equal(cells[0].content, 'let x = 1;');
|
||||
assert.equal(cells[0].leadingWhitespace, '');
|
||||
assert.equal(cells[0].trailingWhitespace, '');
|
||||
assert.equal(cells[0].language, 'javascript');
|
||||
assert.strictEqual(cells.length, 1);
|
||||
assert.strictEqual(cells[0].content, 'let x = 1;');
|
||||
assert.strictEqual(cells[0].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[0].trailingWhitespace, '');
|
||||
assert.strictEqual(cells[0].language, 'javascript');
|
||||
});
|
||||
|
||||
test('code cell, w/whitespace', () => {
|
||||
const cells = parseMarkdown('\n\n```js\nlet x = 1;\n```\n\n');
|
||||
assert.equal(cells.length, 1);
|
||||
assert.equal(cells[0].content, 'let x = 1;');
|
||||
assert.equal(cells[0].leadingWhitespace, '\n\n');
|
||||
assert.equal(cells[0].trailingWhitespace, '\n\n');
|
||||
assert.strictEqual(cells.length, 1);
|
||||
assert.strictEqual(cells[0].content, 'let x = 1;');
|
||||
assert.strictEqual(cells[0].leadingWhitespace, '\n\n');
|
||||
assert.strictEqual(cells[0].trailingWhitespace, '\n\n');
|
||||
});
|
||||
|
||||
test('code cell, markdown', () => {
|
||||
const cells = parseMarkdown('```js\nlet x = 1;\n```\n\n# hello\nfoo\n');
|
||||
assert.equal(cells.length, 2);
|
||||
assert.equal(cells[0].content, 'let x = 1;');
|
||||
assert.equal(cells[0].leadingWhitespace, '');
|
||||
assert.equal(cells[0].trailingWhitespace, '\n\n');
|
||||
assert.strictEqual(cells.length, 2);
|
||||
assert.strictEqual(cells[0].content, 'let x = 1;');
|
||||
assert.strictEqual(cells[0].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[0].trailingWhitespace, '\n\n');
|
||||
|
||||
assert.equal(cells[1].content, '# hello\nfoo');
|
||||
assert.equal(cells[1].leadingWhitespace, '');
|
||||
assert.equal(cells[1].trailingWhitespace, '\n');
|
||||
assert.strictEqual(cells[1].content, '# hello\nfoo');
|
||||
assert.strictEqual(cells[1].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[1].trailingWhitespace, '\n');
|
||||
});
|
||||
|
||||
test('markdown, code cell', () => {
|
||||
const cells = parseMarkdown('# hello\nfoo\n\n```js\nlet x = 1;\n```\n');
|
||||
assert.equal(cells.length, 2);
|
||||
assert.strictEqual(cells.length, 2);
|
||||
|
||||
assert.equal(cells[0].content, '# hello\nfoo');
|
||||
assert.equal(cells[0].leadingWhitespace, '');
|
||||
assert.equal(cells[0].trailingWhitespace, '\n\n');
|
||||
assert.strictEqual(cells[0].content, '# hello\nfoo');
|
||||
assert.strictEqual(cells[0].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[0].trailingWhitespace, '\n\n');
|
||||
|
||||
assert.equal(cells[1].content, 'let x = 1;');
|
||||
assert.equal(cells[1].leadingWhitespace, '');
|
||||
assert.equal(cells[1].trailingWhitespace, '\n');
|
||||
assert.strictEqual(cells[1].content, 'let x = 1;');
|
||||
assert.strictEqual(cells[1].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[1].trailingWhitespace, '\n');
|
||||
});
|
||||
|
||||
test('markdown, code cell with no whitespace between', () => {
|
||||
const cells = parseMarkdown('# hello\nfoo\n```js\nlet x = 1;\n```\n');
|
||||
assert.equal(cells.length, 2);
|
||||
assert.strictEqual(cells.length, 2);
|
||||
|
||||
assert.equal(cells[0].content, '# hello\nfoo');
|
||||
assert.equal(cells[0].leadingWhitespace, '');
|
||||
assert.equal(cells[0].trailingWhitespace, '\n');
|
||||
assert.strictEqual(cells[0].content, '# hello\nfoo');
|
||||
assert.strictEqual(cells[0].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[0].trailingWhitespace, '\n');
|
||||
|
||||
assert.equal(cells[1].content, 'let x = 1;');
|
||||
assert.equal(cells[1].leadingWhitespace, '');
|
||||
assert.equal(cells[1].trailingWhitespace, '\n');
|
||||
assert.strictEqual(cells[1].content, 'let x = 1;');
|
||||
assert.strictEqual(cells[1].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[1].trailingWhitespace, '\n');
|
||||
});
|
||||
|
||||
test('indented code cell', () => {
|
||||
const cells = parseMarkdown(' ```js\n // indented js block\n ```\n# More content');
|
||||
assert.equal(cells.length, 2);
|
||||
assert.strictEqual(cells.length, 2);
|
||||
|
||||
assert.equal(cells[0].content, '// indented js block');
|
||||
assert.equal(cells[0].indentation, ' ');
|
||||
assert.strictEqual(cells[0].content, '// indented js block');
|
||||
assert.strictEqual(cells[0].indentation, ' ');
|
||||
|
||||
assert.equal(cells[1].content, '# More content');
|
||||
assert.strictEqual(cells[1].content, '# More content');
|
||||
});
|
||||
|
||||
test('CRLF', () => {
|
||||
const cells = parseMarkdown('```js\r\nlet x = 1;\r\n```\r\n\r\n# hello\r\nfoo\r\n');
|
||||
assert.equal(cells.length, 2);
|
||||
assert.equal(cells[0].content, 'let x = 1;');
|
||||
assert.equal(cells[0].leadingWhitespace, '');
|
||||
assert.equal(cells[0].trailingWhitespace, '\n\n');
|
||||
assert.strictEqual(cells.length, 2);
|
||||
assert.strictEqual(cells[0].content, 'let x = 1;');
|
||||
assert.strictEqual(cells[0].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[0].trailingWhitespace, '\n\n');
|
||||
|
||||
assert.equal(cells[1].content, '# hello\nfoo');
|
||||
assert.equal(cells[1].leadingWhitespace, '');
|
||||
assert.equal(cells[1].trailingWhitespace, '\n');
|
||||
assert.strictEqual(cells[1].content, '# hello\nfoo');
|
||||
assert.strictEqual(cells[1].leadingWhitespace, '');
|
||||
assert.strictEqual(cells[1].trailingWhitespace, '\n');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -114,7 +114,7 @@ suite('writeMarkdown', () => {
|
|||
function testWriteMarkdown(markdownStr: string) {
|
||||
const cells = parseMarkdown(markdownStr)
|
||||
.map(rawToNotebookCellData);
|
||||
assert.equal(writeCellsToMarkdown(cells), markdownStr);
|
||||
assert.strictEqual(writeCellsToMarkdown(cells), markdownStr);
|
||||
}
|
||||
|
||||
suite('writeMarkdown', () => {
|
||||
|
@ -147,7 +147,7 @@ suite('writeMarkdown', () => {
|
|||
value: 'bar'
|
||||
});
|
||||
|
||||
assert.equal(writeCellsToMarkdown(cells), `# hello\n\nfoo\n\nbar\n`);
|
||||
assert.strictEqual(writeCellsToMarkdown(cells), `# hello\n\nfoo\n\nbar\n`);
|
||||
});
|
||||
|
||||
test('append code cells', () => {
|
||||
|
@ -168,7 +168,7 @@ suite('writeMarkdown', () => {
|
|||
value: 'bar'
|
||||
});
|
||||
|
||||
assert.equal(writeCellsToMarkdown(cells), '```ts\nsome code\n```\n\n```ts\nfoo\n```\n\n```ts\nbar\n```\n');
|
||||
assert.strictEqual(writeCellsToMarkdown(cells), '```ts\nsome code\n```\n\n```ts\nfoo\n```\n\n```ts\nbar\n```\n');
|
||||
});
|
||||
|
||||
test('insert cells', () => {
|
||||
|
@ -189,7 +189,7 @@ suite('writeMarkdown', () => {
|
|||
value: 'bar'
|
||||
});
|
||||
|
||||
assert.equal(writeCellsToMarkdown(cells), '# Hello\n\n```ts\nfoo\n```\n\n```ts\nbar\n```\n\n## Header 2');
|
||||
assert.strictEqual(writeCellsToMarkdown(cells), '# Hello\n\n```ts\nfoo\n```\n\n```ts\nbar\n```\n\n## Header 2');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче