1 | var assert = require('assert'),
|
2 | cleaner = require('./index.js');
|
3 |
|
4 |
|
5 | cleaner.clean('Foo Bar', function (html) {
|
6 | assert.equal(html, 'Foo Bar');
|
7 | });
|
8 |
|
9 |
|
10 | cleaner.clean('Foo Bar', function (html) {
|
11 | assert.equal(html, 'Foo Bar');
|
12 | });
|
13 | cleaner.clean('Foo Bar', {'replace-nbsp': true}, function (html) {
|
14 | assert.equal(html, 'Foo Bar');
|
15 | });
|
16 |
|
17 |
|
18 | cleaner.clean('Foo Bar', function (html) {
|
19 | assert.equal(html, 'Foo Bar');
|
20 | });
|
21 | cleaner.clean('Foo\nBar', function (html) {
|
22 | assert.equal(html, 'Foo Bar');
|
23 | });
|
24 |
|
25 |
|
26 | cleaner.clean('<!-- foo -->', function (html) {
|
27 | assert.equal(html, '<!-- foo -->');
|
28 | });
|
29 | cleaner.clean('<!-- foo -->', {'remove-comments': true}, function (html) {
|
30 | assert.equal(html, '');
|
31 | });
|
32 |
|
33 |
|
34 | cleaner.clean('foo<!-- bar -->qux', function (html) {
|
35 | assert.equal(html, 'foo\n<!-- bar -->\nqux');
|
36 | });
|
37 | cleaner.clean('foo<!-- bar -->qux', {'break-around-comments': false}, function (html) {
|
38 | assert.equal(html, 'foo<!-- bar -->qux');
|
39 | });
|
40 |
|
41 |
|
42 | cleaner.clean('<p>\n</p>', function (html) {
|
43 | assert.equal(html, '<p>\n</p>');
|
44 | });
|
45 | cleaner.clean('<p>\n</p>', {'remove-empty-paras': true}, function (html) {
|
46 | assert.equal(html, '');
|
47 | });
|
48 |
|
49 |
|
50 | cleaner.clean('<font face="arial">foo</font>', function (html) {
|
51 | assert.equal(html, 'foo');
|
52 | });
|
53 |
|
54 |
|
55 | cleaner.clean('<span color="red">foo</span>', function (html) {
|
56 | assert.equal(html, '<span>foo</span>');
|
57 | });
|
58 |
|
59 |
|
60 | cleaner.clean('foo<br>bar', function (html) {
|
61 | assert.equal(html, 'foo<br>\nbar');
|
62 | });
|
63 | cleaner.clean('foo<br>bar', {'break-after-br': false}, function (html) {
|
64 | assert.equal(html, 'foo<br>bar');
|
65 | });
|
66 |
|
67 |
|
68 | cleaner.clean('foo<div></div>bar', function (html) {
|
69 | assert.equal(html, 'foo\n<div>\n</div>\nbar');
|
70 | });
|
71 |
|
72 |
|
73 | cleaner.clean('<div>foo</div>', function (html) {
|
74 | assert.equal(html, '<div>\n foo\n</div>');
|
75 | });
|
76 | cleaner.clean('<div><div>foo</div></div>', function (html) {
|
77 | assert.equal(html, '<div>\n <div>\n foo\n </div>\n</div>');
|
78 | });
|
79 | cleaner.clean('<div>foo</div>', {'indent': ' '}, function (html) {
|
80 | assert.equal(html, '<div>\n foo\n</div>');
|
81 | });
|
82 |
|
83 |
|
84 | cleaner.clean(' foo\n', function (html) {
|
85 | assert.equal(html, 'foo');
|
86 | });
|
87 |
|
88 | console.log('all tests passed');
|