Skip to content

Commit

Permalink
adds unit tests covering Base.generateDiff
Browse files Browse the repository at this point in the history
  • Loading branch information
harrysarson authored and boneskull committed Mar 6, 2018
1 parent bdcb3c3 commit 660bccc
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/reporters/base.spec.js
Expand Up @@ -136,6 +136,36 @@ describe('Base reporter', function () {
});
});

describe('Diff generation', function () {
it('should generate unified diffs if `inlineDiff === false`', function () {
var actual = 'a foo unified diff';
var expected = 'a bar unified diff';

var oldInlineDiffs = Base.inlineDiffs;
Base.inlineDiffs = false;

var output = Base.generateDiff(actual, expected);

Base.inlineDiffs = oldInlineDiffs;

expect(output).to.equal('\n + expected - actual\n\n -a foo unified diff\n +a bar unified diff\n ');
});

it('should generate inline diffs if `inlineDiffs === true`', function () {
var actual = 'a foo inline diff';
var expected = 'a bar inline diff';

var oldInlineDiffs = Base.inlineDiffs;
Base.inlineDiffs = true;

var output = Base.generateDiff(actual, expected);

Base.inlineDiffs = oldInlineDiffs;

expect(output).to.equal(' \n actual expected\n \n a foobar inline diff\n ');
});
});

describe('Inline strings diff', function () {
it('should show single line diff if property set to `true`', function () {
var err = new Error('test');
Expand Down

0 comments on commit 660bccc

Please sign in to comment.