const stripIndent = require('common-tags/lib/stripIndent'); // const docsifyInit = require('../helpers/docsify-init'); const marked = require('marked'); // Suite // ----------------------------------------------------------------------------- describe('render', function() { // Setup & Teardown // ------------------------------------------------------------------------- // beforeEach(async () => { // await docsifyInit(); // }); // Helpers // --------------------------------------------------------------------------- describe('helpers', () => { test('important content', () => { const output = marked('!> Important content'); expect(output).toMatchInlineSnapshot( `"

Important content

"` ); }); test('general tip', () => { const output = marked('?> General tip'); expect(output).toMatchInlineSnapshot( `"

General tip

"` ); }); }); // Lists // --------------------------------------------------------------------------- describe('lists', function() { test('as unordered task list', async function() { const output = marked(stripIndent` - [x] Task 1 - [ ] Task 2 - [ ] Task 3 `); expect(output).toMatchInlineSnapshot( `""` ); }); test('as ordered task list', async function() { const output = marked(stripIndent` 1. [ ] Task 1 2. [x] Task 2 `); expect(output).toMatchInlineSnapshot( `"
"` ); }); test('normal unordered', async function() { const output = marked(stripIndent` - [linktext](link) - just text `); expect(output).toMatchInlineSnapshot( `""` ); }); test('unordered with custom start', async function() { const output = marked(stripIndent` 1. first 2. second text 3. third `); expect(output).toMatchInlineSnapshot( `"
  1. first
  2. second

text

  1. third
"` ); }); test('nested', async function() { const output = marked(stripIndent` - 1 - 2 - 2 a - 2 b - 3 `); expect(output).toMatchInlineSnapshot( `""` ); }); }); // Images // --------------------------------------------------------------------------- describe('images', function() { test('regular', async function() { const output = marked('![alt text](http://imageUrl)'); expect(output).toMatchInlineSnapshot( `"

\\"alt

"` ); }); test('class', async function() { const output = marked( "![alt text](http://imageUrl ':class=someCssClass')" ); expect(output).toMatchInlineSnapshot( `"

\\"alt

"` ); }); test('id', async function() { const output = marked("![alt text](http://imageUrl ':id=someCssID')"); expect(output).toMatchInlineSnapshot( `"

\\"alt

"` ); }); test('no-zoom', async function() { const output = marked("![alt text](http://imageUrl ':no-zoom')"); expect(output).toMatchInlineSnapshot( `"

\\"alt

"` ); }); describe('size', function() { test('width and height', async function() { const output = marked( "![alt text](http://imageUrl ':size=WIDTHxHEIGHT')" ); expect(output).toMatchInlineSnapshot( `"

\\"alt

"` ); }); test('width', async function() { const output = marked("![alt text](http://imageUrl ':size=50')"); expect(output).toMatchInlineSnapshot( `"

\\"alt

"` ); }); }); }); // Headings // --------------------------------------------------------------------------- describe('headings', function() { test('h1', async function() { const output = marked('# h1 tag'); expect(output).toMatchInlineSnapshot( `"

h1 tag

"` ); }); test('h2', async function() { const output = marked('## h2 tag'); expect(output).toMatchInlineSnapshot( `"

h2 tag

"` ); }); test('h3', async function() { const output = marked('### h3 tag'); expect(output).toMatchInlineSnapshot( `"

h3 tag

"` ); }); test('h4', async function() { const output = marked('#### h4 tag'); expect(output).toMatchInlineSnapshot( `"

h4 tag

"` ); }); test('h5', async function() { const output = marked('##### h5 tag'); expect(output).toMatchInlineSnapshot( `"
h5 tag
"` ); }); test('h6', async function() { const output = marked('###### h6 tag'); expect(output).toMatchInlineSnapshot( `"
h6 tag
"` ); }); }); describe('link', function() { test('regular', async function() { const output = marked('[alt text](http://url)'); expect(output).toMatchInlineSnapshot( `"

alt text

"` ); }); test('linkrel', async function() { // const { docsify } = await init('default', { // externalLinkTarget: '_blank', // externalLinkRel: 'noopener', // }); const output = marked('[alt text](http://www.example.com)'); expect(output).toMatchInlineSnapshot( `"

alt text

"` ); }); test('disabled', async function() { const output = marked("[alt text](http://url ':disabled')"); expect(output).toMatchInlineSnapshot( `"

alt text

"` ); }); test('target', async function() { const output = marked("[alt text](http://url ':target=_self')"); expect(output).toMatchInlineSnapshot( `"

alt text

"` ); }); test('class', async function() { const output = marked("[alt text](http://url ':class=someCssClass')"); expect(output).toMatchInlineSnapshot( `"

alt text

"` ); }); test('id', async function() { const output = marked("[alt text](http://url ':id=someCssID')"); expect(output).toMatchInlineSnapshot( `"

alt text

"` ); }); }); });