1 | var wmd = require('../lib/wmd'),
|
2 | jsdom = wmd.postprocessors.jsdom,
|
3 | first_paragraph = wmd.postprocessors.first_paragraph,
|
4 | heading = wmd.postprocessors.heading,
|
5 | html_no_heading = wmd.postprocessors.html_no_heading;
|
6 |
|
7 |
|
8 | function createDoc() {
|
9 | return {
|
10 | html: '<h1>title text</h1>' +
|
11 | '<p>first paragraph</p>' +
|
12 | '<p>second paragrapg</p>'
|
13 | };
|
14 | }
|
15 |
|
16 | exports['jsdom'] = function (test) {
|
17 | var doc = createDoc();
|
18 | var doc2 = jsdom(doc);
|
19 | test.equal(doc2.html, doc.html);
|
20 | test.equal(doc2.window.document.innerHTML, doc.html);
|
21 | test.equal(
|
22 | doc2.window.document.getElementsByTagName("H1")[0].innerHTML,
|
23 | 'title text'
|
24 | );
|
25 | test.done();
|
26 | };
|
27 |
|
28 | exports['first_paragraph'] = function (test) {
|
29 | var doc = createDoc();
|
30 | var doc2 = first_paragraph(doc);
|
31 | test.equal(doc2.first_paragraph, 'first paragraph');
|
32 | test.done();
|
33 | };
|
34 |
|
35 | exports['first_paragraph without p tags'] = function (test) {
|
36 | var doc = {html: '<h1>test</h1>'};
|
37 | var doc2 = first_paragraph(doc);
|
38 | test.equal(doc2.first_paragraph, null);
|
39 | test.done();
|
40 | };
|
41 |
|
42 | exports['heading'] = function (test) {
|
43 | var doc = createDoc();
|
44 | var doc2 = heading(doc);
|
45 | test.equal(doc2.heading, 'title text');
|
46 | test.done();
|
47 | };
|
48 |
|
49 | exports['heading without h1 tag'] = function (test) {
|
50 | var doc = {html: '<p>test</p>'};
|
51 | var doc2 = heading(doc);
|
52 | test.equal(doc2.heading, null);
|
53 | test.done();
|
54 | };
|
55 |
|
56 | exports['html_no_heading'] = function (test) {
|
57 | var doc = createDoc();
|
58 | var doc2 = html_no_heading(doc);
|
59 | test.equal(
|
60 | doc2.html_no_heading,
|
61 | '<p>first paragraph</p><p>second paragrapg</p>'
|
62 | );
|
63 | test.done();
|
64 | };
|
65 |
|
66 | exports['html_no_heading without h1 tag'] = function (test) {
|
67 | var doc = {html: '<p>test</p>'};
|
68 | var doc2 = html_no_heading(doc);
|
69 | test.equal(doc2.html_no_heading, '<p>test</p>');
|
70 | test.done();
|
71 | };
|