summaryrefslogtreecommitdiffstats
path: root/lib/output/modifiers/__tests__/addHeadingId.js
blob: 7277440ea81b359bf4c116dce0576c3556acc308 (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
27
28
29
jest.autoMockOff();

var cheerio = require('cheerio');

describe('addHeadingId', function() {
    var addHeadingId = require('../addHeadingId');

    pit('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>');
        });
    });

    pit('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>');
        });
    });
});