Skip to content

Commit 8f3c3b6

Browse files
committed
Update tests
1 parent 9678616 commit 8f3c3b6

5 files changed

Lines changed: 18 additions & 60 deletions

File tree

test/diffHtml.js

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,13 @@ function readFiles(f1, f2) {
1212

1313
describe('\'diffHtml\'', function () {
1414

15-
it('must not be diffs', function () {
16-
var htmlDiffer = new HtmlDiffer(),
17-
18-
files = readFiles('1.html', '_1.html'),
19-
20-
res = [ {
21-
value: '<!DOCTYPE html>\n<html>\n<head lang="en">\n <meta charset="UTF-8">\n <title></title>\n</head>\n<body>\nText\n</body>\n</html>\n'
22-
} ];
23-
24-
htmlDiffer.diffHtml(files.html1, files.html2).must.be.eql(res);
25-
});
26-
27-
it('must be diffs', function () {
28-
var htmlDiffer = new HtmlDiffer(),
29-
30-
files = readFiles('2.html', '_2.html'),
31-
32-
res = [ {
33-
value: '<!DOCTYPE html><html><head lang="en"><meta charset="UTF-8"><title></title></head><body>\n',
34-
added: undefined,
35-
removed: undefined
36-
}, {
37-
value: '!',
38-
added: true,
39-
removed: undefined
40-
}, {
41-
value: 'Text',
42-
added: undefined,
43-
removed: undefined
44-
}, {
45-
value: '!',
46-
added: true,
47-
removed: undefined
48-
}, {
49-
value: '\n</body></html>',
50-
added: undefined,
51-
removed: undefined
52-
} ];
53-
54-
htmlDiffer.diffHtml(files.html1, files.html2).must.be.eql(res);
55-
});
56-
5715
it('must set options', function () {
58-
var htmlDiffer = new HtmlDiffer({ ignoreHtmlAttrs: ['id', 'for'] }),
16+
var htmlDiffer = new HtmlDiffer({ ignoreHtmlAttrs: ['id', 'for'], ignoreWhitespace: true }),
5917

6018
files = readFiles('3.html', '_3.html'),
6119

6220
res = [ {
63-
value: '<html><head><title>Test</title></head><body><label for="">label for input</label><input id=""></body></html>',
21+
value: '<html> <head> <title>Test</title> </head> <body> <label for="">label for input</label> <input id=""> </body> </html> ',
6422
added: undefined,
6523
removed: undefined
6624
} ];

test/fixtures/9.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<title></title>
66
</head>
77
<body>
8-
<label for="random">label for input</label>
9-
<input id="random">
10-
<div onclick="return {&quot;a&quot;:{&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:&quot;function() { return true; }&quot;}}" ondblclick="return {&quot;a&quot;:{&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:&quot;function() { return true; }&quot;}}"></div>
11-
<div data-bem="{&quot;a&quot;:{&quot;a&quot;:{&quot;x&quot;:&quot;xx&quot;,&quot;y&quot;:&quot;yy&quot;},&quot;b&quot;:&quot;bb&quot;,&quot;c&quot;:&quot;cc&quot;},&quot;b&quot;:&quot;bb&quot;}">
8+
<label for="random">label for input</label>
9+
<input id="random">
10+
<div onclick="return {&quot;a&quot;:{&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:&quot;function() { return true; }&quot;}}" ondblclick="return {&quot;a&quot;:{&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:&quot;function() { return true; }&quot;}}"></div>
11+
<div data-bem="{&quot;a&quot;:{&quot;a&quot;:{&quot;x&quot;:&quot;xx&quot;,&quot;y&quot;:&quot;yy&quot;},&quot;b&quot;:&quot;bb&quot;,&quot;c&quot;:&quot;cc&quot;},&quot;b&quot;:&quot;bb&quot;}">
1212
</body>
1313
</html>

test/fixtures/_9.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<!DOCTYPE html>
22
<html>
33
<head lang="en">
4-
<meta charset="UTF-8">
5-
<title></title>
4+
<meta charset="UTF-8">
5+
<title></title>
66
</head>
77
<body>
8-
<label for="sfsdfksdf">label for input</label>
9-
<input id="sfsdfksdf">
10-
<div onclick="return {&quot;a&quot;:{&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:&quot;function() { return true; }&quot;}}" ondblclick="return {&quot;a&quot;:{&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:&quot;function() { return true; }&quot;}}"></div>
11-
<div data-bem="{&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:{&quot;c&quot;:&quot;cc&quot;,&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:{&quot;y&quot;:&quot;yy&quot;,&quot;x&quot;:&quot;xx&quot;}}}">
8+
<label for="sfsdfksdf">label for input</label>
9+
<input id="sfsdfksdf">
10+
<div onclick="return {&quot;a&quot;:{&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:&quot;function() { return true; }&quot;}}" ondblclick="return {&quot;a&quot;:{&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:&quot;function() { return true; }&quot;}}"></div>
11+
<div data-bem="{&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:{&quot;c&quot;:&quot;cc&quot;,&quot;b&quot;:&quot;bb&quot;,&quot;a&quot;:{&quot;y&quot;:&quot;yy&quot;,&quot;x&quot;:&quot;xx&quot;}}}">
1212
</body>
1313
</html>

test/getDiffText.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('\'diffHtml\'', function () {
1212
removed: undefined
1313
} ];
1414

15-
diffLoger.getDiffText(inp, { charsAroundDiff: 20 } ).must.be.equal('');
15+
diffLoger.getDiffText(inp, { charsAroundDiff: 20 }).must.be.equal('');
1616
});
1717

1818
it('must return a diff string', function () {
@@ -41,7 +41,7 @@ describe('\'diffHtml\'', function () {
4141

4242
out = '\n...\n' + 'texttexttexttexttext'.grey + '!'.inverse.green + 'Text'.grey + '!'.inverse.green + 'texttexttexttext'.grey;
4343

44-
diffLoger.getDiffText(inp, { charsAroundDiff: 20 } ).must.be.eql(out);
44+
diffLoger.getDiffText(inp, { charsAroundDiff: 20 }).must.be.eql(out);
4545
});
4646

4747
it('must consider negative value of \'charsAroundDiff\' option', function () {
@@ -51,7 +51,7 @@ describe('\'diffHtml\'', function () {
5151
removed: undefined
5252
} ];
5353

54-
diffLoger.getDiffText(inp, { charsAroundDiff: -5 } ).must.be.equal('');
54+
diffLoger.getDiffText(inp, { charsAroundDiff: -5 }).must.be.equal('');
5555
});
5656

5757

@@ -70,7 +70,7 @@ describe('\'diffHtml\'', function () {
7070

7171
out = '\n' + 'texttexttexttexttexttexttexttexttexttexttext'.inverse.green + 'ololoololoololoololoololoololoololoololoolol'.inverse.red;
7272

73-
diffLoger.getDiffText(inp, { charsAroundDiff: 20 } ).must.be.eql(out);
73+
diffLoger.getDiffText(inp, { charsAroundDiff: 20 }).must.be.eql(out);
7474
});
7575

7676
it('must return a diff on the beginning of the input', function () {
@@ -128,7 +128,7 @@ describe('\'diffHtml\'', function () {
128128

129129
out = '\n...\n' + 'texttexttexttexttext'.grey + 'text'.inverse.red + 'texttexttexttexttext'.grey + '\n...\n' + 'texttexttexttexttext'.grey + '!'.inverse.green + 'text'.grey + '!'.inverse.green + 'texttexttexttexttext'.grey;
130130

131-
diffLoger.getDiffText(inp, { charsAroundDiff: 20 } ).must.be.eql(out);
131+
diffLoger.getDiffText(inp, { charsAroundDiff: 20 }).must.be.eql(out);
132132
});
133133

134134
});

test/isEqual.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('\'isEqual\'', function () {
6161
});
6262

6363
it('must ignore space characters', function () {
64-
var htmlDiffer = new HtmlDiffer({ ignoreWhitespaces: true }),
64+
var htmlDiffer = new HtmlDiffer({ ignoreWhitespace: true }),
6565

6666
files = readFiles('7.html', '_7.html');
6767

0 commit comments

Comments
 (0)