Skip to content

Commit 660bccc

Browse files
harrysarsonboneskull
authored andcommitted
adds unit tests covering Base.generateDiff
1 parent bdcb3c3 commit 660bccc

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎test/reporters/base.spec.js‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,36 @@ describe('Base reporter', function () {
136136
});
137137
});
138138

139+
describe('Diff generation', function () {
140+
it('should generate unified diffs if `inlineDiff === false`', function () {
141+
var actual = 'a foo unified diff';
142+
var expected = 'a bar unified diff';
143+
144+
var oldInlineDiffs = Base.inlineDiffs;
145+
Base.inlineDiffs = false;
146+
147+
var output = Base.generateDiff(actual, expected);
148+
149+
Base.inlineDiffs = oldInlineDiffs;
150+
151+
expect(output).to.equal('\n + expected - actual\n\n -a foo unified diff\n +a bar unified diff\n ');
152+
});
153+
154+
it('should generate inline diffs if `inlineDiffs === true`', function () {
155+
var actual = 'a foo inline diff';
156+
var expected = 'a bar inline diff';
157+
158+
var oldInlineDiffs = Base.inlineDiffs;
159+
Base.inlineDiffs = true;
160+
161+
var output = Base.generateDiff(actual, expected);
162+
163+
Base.inlineDiffs = oldInlineDiffs;
164+
165+
expect(output).to.equal(' \n actual expected\n \n a foobar inline diff\n ');
166+
});
167+
});
168+
139169
describe('Inline strings diff', function () {
140170
it('should show single line diff if property set to `true`', function () {
141171
var err = new Error('test');

0 commit comments

Comments
 (0)