embedded-trainings-2020/down-the-stack-book/node_modules/@kazumatu981/markdown-it-kroki/tests/unittest/plugin-core.static-methods.test.js
Jonathan Pallant (Ferrous Systems) a4ee38540d
Ensure marp can render slides.
We bundle markdown-it-kroki, which can add mermaid diagrams to marp slides using https://kroki.io.
2023-03-22 10:28:51 +00:00

49 lines
2.3 KiB
JavaScript

const expect = require('chai').expect;
const { MarkdownItKrokiCore } = require('../../lib/plugin-core');
describe('# [unit-test] plugin-core.js', () => {
describe('## static method: readLanguageAndAltText() - language', () => {
[
{ test: null, expected: '' },
{ test: undefined, expected: '' },
{ test: '', expected: '' },
{ test: ' ', expected: '' },
{ test: 'plantuml', expected: 'plantuml' },
{ test: ' plantuml', expected: 'plantuml' },
{ test: 'plantuml ', expected: 'plantuml' },
{ test: 'plantuml +++', expected: 'plantuml' },
{ test: 'html+md', expected: 'html+md' },
{ test: 'graphviz[]', expected: 'graphviz' },
{ test: 'graphviz[test]', expected: 'graphviz' },
{ test: 'graphviz [test test]', expected: 'graphviz' },
].forEach(testCase => {
it(`### Can read diagramLanguage. in case \'${testCase.test}\'`, () => {
const actual = MarkdownItKrokiCore.readLanguageAndAltText(testCase.test);
const expected = testCase.expected;
expect(actual.language).to.be.equal(expected);
})
});
});
describe('## static method: readLanguageAndAltText() - alt', () => {
[
{ test: null, expected: '' },
{ test: undefined, expected: '' },
{ test: '', expected: '' },
{ test: ' ', expected: '' },
{ test: 'plantuml', expected: '' },
{ test: ' plantuml', expected: '' },
{ test: 'plantuml ', expected: '' },
{ test: 'plantuml +++', expected: '' },
{ test: 'html+md', expected: '' },
{ test: 'graphviz[]', expected: '' },
{ test: 'graphviz[test]', expected: 'test' },
{ test: 'graphviz [test test]', expected: 'test test' },
].forEach(testCase => {
it(`### Can read diagramLanguage. in case \'${testCase.test}\'`, () => {
const actual = MarkdownItKrokiCore.readLanguageAndAltText(testCase.test);
const expected = testCase.expected;
expect(actual.alt).to.be.equal(expected);
})
});
});
});