From 82576e54a44fad21b5de58b9b531bbec9a19bf81 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Tue, 17 Aug 2021 14:02:18 -0700 Subject: [PATCH] Add more marked.js tests (#16800) --- .../test/browser/notebookMarkdown.test.ts | 107 +++++++++++++----- 1 file changed, 77 insertions(+), 30 deletions(-) diff --git a/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts b/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts index 083f2d13a6..ac00aae031 100644 --- a/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts +++ b/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts @@ -108,48 +108,95 @@ suite('NotebookMarkdownRenderer', () => { * This suite contains tests that verify the expected parsing results for the current version of marked.js which were determined to have * changed in newer versions of marked.js being brought in. They are put here as a staging ground to keep track of these differences, but once the * differences are understood should be moved out into a generic test like the ones above. + * + * Each suite corresponds to a single notebook - identified by its azdata_notebook_guid. Each test within that suite corresponds to the + * azdata_cell_guid of the cell that originally demonstrated the issue. */ suite('parse output differences between current marked.js and newer versions', function (): void { - test('1', function (): void { - const markdown = '1) Item 1\n\n2) Item 2\n\n 1) Sub-item 1\n\n 2) Sub-item 2\n\n'; - const expectedValue = '
    \n
  1. Item 1

  2. \n
  3. Item 2

      \n
    1. Sub-item 1

    2. \n
    3. Sub-item 2

    4. \n
    \n
  4. \n
\n'; - const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; - assert.strictEqual(result, expectedValue); + suite('Notebook 91e764e1-95ce-4101-a08b-d1d7888649a4', function (): void { + test('Cell 74d8d9db-1b08-4a50-ac2a-e35a16a6af07', function (): void { + const markdown = '1) Item 1\n\n2) Item 2\n\n 1) Sub-item 1\n\n 2) Sub-item 2\n\n'; + const expectedValue = '
    \n
  1. Item 1

  2. \n
  3. Item 2

      \n
    1. Sub-item 1

    2. \n
    3. Sub-item 2

    4. \n
    \n
  4. \n
\n'; + const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; + assert.strictEqual(result, expectedValue); + }); }); - test('2', function (): void { - const markdown = ' ![](attachment:image.png)'; - const expectedValue = '
![](attachment:image.png)
\n'; - const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; - assert.strictEqual(result, expectedValue); + suite('Notebook 15f7b65e-5bcf-43bd-9e75-84c47a0a6e84', function (): void { + test('Cell 8b48e63f-abdd-4306-a988-b673d13aab06', function (): void { + const markdown = ' ![](attachment:image.png)'; + const expectedValue = '
![](attachment:image.png)
\n'; + const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; + assert.strictEqual(result, expectedValue); + }); }); - test('3', function (): void { - const markdown = 'Some text **%appdata%\\*****Path\\\\To\\\\Folder\\\\<******FileName**>.ext** into **...\\\\Another\\\\****Path\\\\**\n\n'; - const expectedValue = '

Some text %appdata%***Path\\To\\Folder\\<******FileName**>.ext** into ...\\Another\\**Path\\**

'; - const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; - assert.strictEqual(result, expectedValue); + suite('Notebook e054f8e1-f014-4c7c-8a55-65bf13b22bb5', function (): void { + test('Cell 0981d264-25f5-489c-901b-74608297f7fc', function (): void { + const markdown = 'Some text **%appdata%\\*****Path\\\\To\\\\Folder\\\\<******FileName**>.ext** into **...\\\\Another\\\\****Path\\\\**\n\n'; + const expectedValue = '

Some text %appdata%***Path\\To\\Folder\\<******FileName**>.ext** into ...\\Another\\**Path\\**

'; + const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; + assert.strictEqual(result, expectedValue); + }); }); - test('4', function (): void { - const markdown = '# Heading 1\n- Some text\n\n \n\n- ## Heading 2'; - const expectedValue = '

Heading 1

\n\n\n'; - const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; - assert.strictEqual(result, expectedValue); + suite('Notebook ????', function (): void { + test('Cell b74f16a2-5b2e-4e58-8c79-9688d6b1f62a', function (): void { + const markdown = '# Heading 1\n- Some text\n\n \n\n- ## Heading 2'; + const expectedValue = '

Heading 1

\n\n\n'; + const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; + assert.strictEqual(result, expectedValue); + }); }); - test('5', function (): void { - const markdown = `Some text\n\n Some more text`; - const expectedValue = '

Some text

  Some more text
\n'; - const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; - assert.strictEqual(result, expectedValue); + suite('Notebook 56e15822-f884-42ed-944c-789ff8961ba9', function (): void { + test('Cell 8b341e16-113f-4ec4-b937-c02884bdb9f3', function (): void { + const markdown = 'Some text\n\n Some more text'; + const expectedValue = '

Some text

  Some more text
\n'; + const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; + assert.strictEqual(result, expectedValue); + }); }); - test('6', function (): void { - const markdown = `# heading\n##`; - const expectedValue = `

heading

\n

##

`; - const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; - assert.strictEqual(result, expectedValue); + suite('Notebook 03b95d90-a0fc-43c8-b77b-d506f2002904', function (): void { + test('Cell e557e19c-8afa-40e4-a61d-ab08443562ee', function (): void { + const markdown = '# heading\n##'; + const expectedValue = '

heading

\n

##

'; + const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; + assert.strictEqual(result, expectedValue); + }); + }); + + suite('Notebook 8c6d7dc3-4cc9-4b23-93f6-a556a6d5c6f2', function (): void { + test('Cell 241d5f74-ba48-4ec4-be0e-02182f20f691', function (): void { + const markdown = '1. List item text\n\n \n\n a. sub-list item'; + const expectedValue = '
    \n
  1. List item text
  2. \n
\n
a. sub-list item
\n'; + const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; + assert.strictEqual(result, expectedValue); + }); + + test('Cell 8e45da0e-5c24-469e-8ae5-671313bd54a1', function (): void { + const markdown = '1. List Item\n\n \n\n2. List Item 2'; + const expectedValue = '
    \n
  1. List Item
  2. \n
\n
    \n
  1. List Item 2
  2. \n
\n'; + const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; + assert.strictEqual(result, expectedValue); + }); + }); + + suite('Notebook 1a0c01d2-a688-4e51-b39f-04cffb25e7ca', function (): void { + test('Cell a2b18efc-bb62-49fa-913d-e953677150ca', function (): void { + const markdown = '1. List Item\r\n\nText on new line\r\n\n a. Sub List Item'; + const expectedValue = '
    \n
  1. List Item
  2. \n
\n

Text on new line

a. Sub List Item
\n'; + const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; + assert.strictEqual(result, expectedValue); + }); + + test('Cell e6ad1eb3-7409-4199-9592-9d13f1e2d8a0', function (): void { + const markdown = '1. Text \n\nMore text \n\n a. Sub-Text'; + const expectedValue = '
    \n
  1. Text
  2. \n
\n

More text

a. Sub-Text
\n'; + const result = notebookMarkdownRenderer.renderMarkdown({ value: markdown, isTrusted: true }).innerHTML; + assert.strictEqual(result, expectedValue); + }); }); }); });