-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathspec.js
60 lines (49 loc) · 1.34 KB
/
spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const assert = require('assert');
const markt = require('./');
describe('markt', async () => {
it('without a template, converts to markdown', async () => {
const res = await markt('*Hello*');
assert.strictEqual(
res,
'<p><em>Hello</em></p>',
);
});
it('fills pattern in template', async () => {
const res = await markt('*Hello*', '{{content}}');
assert(
res.includes('<p><em>Hello</em></p>'),
);
});
it('pattern can be padded with white space', async () => {
expect(
await markt('*Hello*', '{{ content }}'),
).to.equal(
'<p><em>Hello</em></p>',
);
});
it('test options object', async () => {
const res = await markt('*Hello*', {
template: '{{title}} {{content}}',
title: 'the title',
});
expect(res).to.include('<p><em>Hello</em></p>');
expect(res).to.include('the title');
expect(res).to.not.include('{{content}}');
expect(res).to.not.include('{{title}}');
});
it('uses preset templates', async () => {
const res = await markt('*Hello*', {
preset: 'plain',
title: 'Hi',
});
expect(res).to.include('<!DOCTYPE html>');
expect(res).to.include('<title>Hi</title>');
});
it('falls back to default template when preset is not found', async () => {
const test = async () => await markt('*Hello*', {
preset: 'other',
title: 'Hi',
});
return expect(test()).to.be.rejected;
});
});