-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
76 lines (66 loc) · 1.87 KB
/
test.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var DiffText = require('./');
var expect = require('expect');
describe('diff-text', function() {
it('1. input null', function() {
expect(DiffText.bind(null, null)).toThrow('Text should not be null.');
expect(DiffText.bind(undefined, undefined)).toThrow('Text should not be null.');
expect(DiffText.bind(null, undefined)).toThrow('Text should not be null.');
expect(DiffText.bind(undefined, null)).toThrow('Text should not be null.');
expect(DiffText.bind(null, '12')).toThrow('Text should not be null.');
expect(DiffText.bind('12', undefined)).toThrow('Text should not be null.');
});
it('2. input empty', function() {
expect(DiffText('', '')).toEqual([]);
});
it('3. input same', function() {
expect(DiffText('difftext', 'difftext')).toEqual([
[0, 'difftext']
]);
expect(DiffText('123', '123')).toEqual([
[0, '123']
]);
});
it('4. input just one edit.', function() {
expect(DiffText('', 'diff-text')).toEqual([
[1, 'diff-text']
]);
expect(DiffText('difftext', 'diff-text')).toEqual([
[0, 'diff'],
[1, '-'],
[0, 'text']
]);
expect(DiffText('diff-text', 'difftext')).toEqual([
[0, 'diff'],
[-1, '-'],
[0, 'text']
]);
});
it('5. input just two edit.', function() {
expect(DiffText('diff12345text', 'diff234text')).toEqual([
[0, 'diff'],
[-1, '1'],
[0, '234'],
[-1, '5'],
[0, 'text']
]);
expect(DiffText('diff234text', 'diff12345text')).toEqual([
[0, 'diff'],
[1, '1'],
[0, '234'],
[1, '5'],
[0, 'text']
]);
expect(DiffText('diff+text', 'diff-text')).toEqual([
[0, 'diff'],
[-1, '+'],
[1, '-'],
[0, 'text']
]);
expect(DiffText('diff---text', 'diff+++text')).toEqual([
[0, 'diff'],
[-1, '---'],
[1, '+++'],
[0, 'text']
]);
});
});