forked from naturalatlas/htmldiff.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdiff.spec.js
More file actions
48 lines (39 loc) · 1.55 KB
/
Copy pathdiff.spec.js
File metadata and controls
48 lines (39 loc) · 1.55 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
describe('Diff', function(){
var cut, res;
beforeEach(function(){
cut = require('../js/htmldiff');
});
describe('When both inputs are the same', function(){
beforeEach(function(){
res = cut('input text', 'input text');
});
it('should return the text', function(){
expect(res).equal('input text');
});
}); // describe('When both inputs are the same')
describe('When a letter is added', function(){
beforeEach(function(){
res = cut('input', 'input 2');
});
it('should mark the new letter', function(){
expect(res).to.equal('input<ins> 2</ins>');
});
}); // describe('When a letter is added')
describe('Whitespace differences', function(){
it('should collapse adjacent whitespace', function(){
expect(cut('Much \n\t spaces', 'Much spaces')).to.equal('Much spaces');
});
it('should consider non-breaking spaces as equal', function(){
expect(cut('Hello world', 'Hello world')).to.equal('Hello world');
});
it('should consider non-breaking spaces and non-adjacent regular spaces as equal', function(){
expect(cut('Hello world', 'Hello world')).to.equal('Hello world');
});
}); // describe('Whitespace differences')
describe('When a class name is specified', function(){
it('should include the class in the wrapper tags', function(){
expect(cut('input', 'input 2', 'diff-result')).to.equal(
'input<ins class="diff-result"> 2</ins>');
});
}); // describe('When a class name is specified')
}); // describe('Diff')