/
options.js
46 lines (38 loc) · 1.19 KB
/
options.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
/* jshint mocha: true, maxlen: false */
import posthtml from '../index.js';
import { expect } from 'chai';
const beforeHTML = '<div class="button"><rect/><div class="button__text">Text</div></div>';
const options = { singleTags: ['rect'], closingSingleTag: 'slash' };
function test(html, done) {
posthtml().process(html, options).then(result => {
expect(beforeHTML).to.eql(result.html);
done();
}).catch(error => done(error));
}
describe('Set options', () => {
it('html eqval', done => {
test(beforeHTML, done);
});
});
describe('Skip html parsing & use tree from options.', () => {
let tree = [{
tag: 'div',
attrs: { class: 'button' },
content:[
{ tag: 'rect' },
{
attrs: { class: 'button__text' },
content: ['Text']
}
]
}];
it('Set use tree', done => {
options.skipParse = true;
expect(posthtml()
.process(tree, options)
.then(result => {
expect(beforeHTML).to.eql(result.html);
done();
}).catch(error => done(error)));
});
});