Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luwol03 committed Jun 25, 2021
1 parent 8f5cbad commit 633f241
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion test/unit/render-util.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { removeAtag } = require('../../src/core/render/utils');
const {
removeAtag,
getAndRemoveConfig,
} = require('../../src/core/render/utils');

const { tree } = require(`../../src/core/render/tpl`);

Expand All @@ -16,6 +19,46 @@ describe('core/render/utils', () => {
expect(result).toEqual('content');
});
});

// getAndRemoveConfig()
// ---------------------------------------------------------------------------
describe('getAndRemoveConfig()', () => {
test('parse simple config', () => {
const result = getAndRemoveConfig(
`[filename](_media/example.md ':include')`
);

expect(result).toMatchObject({
config: {},
str: `[filename](_media/example.md ':include')`,
});
});

test('parse config with arguments', () => {
const result = getAndRemoveConfig(
`[filename](_media/example.md ':include :foo=bar :baz test')`
);

expect(result).toMatchObject({
config: {
foo: 'bar',
baz: true,
},
str: `[filename](_media/example.md ':include test')`,
});
});

test('parse config with double quotes', () => {
const result = getAndRemoveConfig(
`[filename](_media/example.md ":include")`
);

expect(result).toMatchObject({
config: {},
str: `[filename](_media/example.md ":include")`,
});
});
});
});

describe('core/render/tpl', () => {
Expand Down

0 comments on commit 633f241

Please sign in to comment.