summaryrefslogtreecommitdiffstats
path: root/lib/output/modifiers/__tests__/addHeadingId.js
blob: a3b1d81f724047ca5eb826beb4ab7223e72af33f (plain)
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
var cheerio = require('cheerio');
var addHeadingId = require('../addHeadingId');

describe('addHeadingId', function() {
    it('should add an ID if none', function() {
        var $ = cheerio.load('<h1>Hello World</h1><h2>Cool !!</h2>');

        return addHeadingId($)
        .then(function() {
            var html = $.html();
            expect(html).toBe('<h1 id="hello-world">Hello World</h1><h2 id="cool-">Cool !!</h2>');
        });
    });

    it('should not change existing IDs', function() {
        var $ = cheerio.load('<h1 id="awesome">Hello World</h1>');

        return addHeadingId($)
        .then(function() {
            var html = $.html();
            expect(html).toBe('<h1 id="awesome">Hello World</h1>');
        });
    });
});