import stripIndent from 'common-tags/lib/stripIndent/index.js';
import docsifyInit from '../helpers/docsify-init.js';
// Suite
// -----------------------------------------------------------------------------
describe('render', function () {
// Setup & Teardown
// -------------------------------------------------------------------------
beforeEach(async () => {
await docsifyInit();
});
// Helpers
// ---------------------------------------------------------------------------
describe('helpers', () => {
test('important content', () => {
const output = window.marked('!> Important content');
expect(output).toMatchInlineSnapshot(
`"
Important content
"`
);
});
test('general tip', () => {
const output = window.marked('?> General tip');
expect(output).toMatchInlineSnapshot(
`"General tip
"`
);
});
});
// Lists
// ---------------------------------------------------------------------------
describe('lists', function () {
test('as unordered task list', async function () {
const output = window.marked(stripIndent`
- [x] Task 1
- [ ] Task 2
- [ ] Task 3
`);
expect(output).toMatchInlineSnapshot(
`""`
);
});
test('as ordered task list', async function () {
const output = window.marked(stripIndent`
1. [ ] Task 1
2. [x] Task 2
`);
expect(output).toMatchInlineSnapshot(
`" Task 1 Task 2 "`
);
});
test('normal unordered', async function () {
const output = window.marked(stripIndent`
- [linktext](link)
- just text
`);
expect(output).toMatchInlineSnapshot(
`""`
);
});
test('unordered with custom start', async function () {
const output = window.marked(stripIndent`
1. first
2. second
text
3. third
`);
expect(output).toMatchInlineSnapshot(
`"first second text
third "`
);
});
test('nested', async function () {
const output = window.marked(stripIndent`
- 1
- 2
- 2 a
- 2 b
- 3
`);
expect(output).toMatchInlineSnapshot(
`""`
);
});
});
// Images
// ---------------------------------------------------------------------------
describe('images', function () {
test('regular', async function () {
const output = window.marked('');
expect(output).toMatchInlineSnapshot(
`"
"`
);
});
test('class', async function () {
const output = window.marked(
""
);
expect(output).toMatchInlineSnapshot(
`"
"`
);
});
test('id', async function () {
const output = window.marked(
""
);
expect(output).toMatchInlineSnapshot(
`"
"`
);
});
test('no-zoom', async function () {
const output = window.marked("");
expect(output).toMatchInlineSnapshot(
`"
"`
);
});
describe('size', function () {
test('width and height', async function () {
const output = window.marked(
""
);
expect(output).toMatchInlineSnapshot(
`"
"`
);
});
test('width', async function () {
const output = window.marked("");
expect(output).toMatchInlineSnapshot(
`"
"`
);
});
});
});
// Headings
// ---------------------------------------------------------------------------
describe('headings', function () {
test('h1', async function () {
const output = window.marked('# h1 tag');
expect(output).toMatchInlineSnapshot(
`""`
);
});
test('h2', async function () {
const output = window.marked('## h2 tag');
expect(output).toMatchInlineSnapshot(
`""`
);
});
test('h3', async function () {
const output = window.marked('### h3 tag');
expect(output).toMatchInlineSnapshot(
`""`
);
});
test('h4', async function () {
const output = window.marked('#### h4 tag');
expect(output).toMatchInlineSnapshot(
`""`
);
});
test('h5', async function () {
const output = window.marked('##### h5 tag');
expect(output).toMatchInlineSnapshot(
`""`
);
});
test('h6', async function () {
const output = window.marked('###### h6 tag');
expect(output).toMatchInlineSnapshot(
`""`
);
});
});
describe('link', function () {
test('regular', async function () {
const output = window.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 = window.marked('[alt text](http://www.example.com)');
expect(output).toMatchInlineSnapshot(
`"alt text
"`
);
});
test('disabled', async function () {
const output = window.marked("[alt text](http://url ':disabled')");
expect(output).toMatchInlineSnapshot(
`"alt text
"`
);
});
test('target', async function () {
const output = window.marked("[alt text](http://url ':target=_self')");
expect(output).toMatchInlineSnapshot(
`"alt text
"`
);
});
test('class', async function () {
const output = window.marked(
"[alt text](http://url ':class=someCssClass')"
);
expect(output).toMatchInlineSnapshot(
`"alt text
"`
);
});
test('id', async function () {
const output = window.marked("[alt text](http://url ':id=someCssID')");
expect(output).toMatchInlineSnapshot(
`"alt text
"`
);
});
});
});