-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathcheckbox.test.ts
68 lines (61 loc) · 2.33 KB
/
checkbox.test.ts
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
61
62
63
64
65
66
67
68
'use strict';
import path from 'path';
import plugin from '../src/transform/plugins/checkbox';
import MarkdownIt from 'markdown-it';
const generate = require('markdown-it-testgen');
const assert = require('assert');
describe('markdown-it-checkbox', function () {
describe('markdown-it-checkbox()', function () {
const md = new MarkdownIt({});
md.use(plugin, {
divWrap: false,
});
generate(path.join(__dirname, 'data/checkbox/checkbox.txt'), md);
return it('should pass irrelevant markdown', function () {
const res = md.render('# test');
assert.equal(res, '<h1>test</h1>\n');
});
});
return describe('markdown-it-checkbox(options)', function () {
it('should should optionally wrap arround a div layer', function () {
const md = new MarkdownIt({});
md.use(plugin);
const res = md.render('[X] test written');
assert.equal(
res,
'<div class="checkbox">\n' +
'<input type="checkbox" id="checkbox0" disabled="" checked="true">\n' +
'<label for="checkbox0">test written</label>\n' +
'</div>\n',
);
});
it('should should optionally change class of div layer', function () {
const md = new MarkdownIt({});
md.use(plugin, {
divClass: 'cb',
});
const res = md.render('[X] test written');
assert.equal(
res,
'<div class="cb">\n' +
'<input type="checkbox" id="checkbox0" disabled="" checked="true">\n' +
'<label for="checkbox0">test written</label>\n' +
'</div>\n',
);
});
return it('should should optionally change the id', function () {
const md = new MarkdownIt({});
md.use(plugin, {
idPrefix: 'cb',
});
const res = md.render('[X] test written');
assert.equal(
res,
'<div class="checkbox">\n' +
'<input type="checkbox" id="cb0" disabled="" checked="true">\n' +
'<label for="cb0">test written</label>\n' +
'</div>\n',
);
});
});
});