mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-06-09 17:09:26 +00:00
49 lines
2.3 KiB
JavaScript
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);
|
||
|
})
|
||
|
});
|
||
|
});
|
||
|
});
|