Skip to content

Commit 8df5727

Browse files
harrysarsonboneskull
authored andcommitted
Tidies up code after review
1 parent 660bccc commit 8df5727

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

lib/reporters/base.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,14 @@ function stringifyDiffObjs (err) {
172172
* The diff will be either inline or unified dependant on the value
173173
* of `Base.inlineDiff`.
174174
*
175-
* @api private
176-
* @param {String} actual
177-
* @param {String} expected
175+
* @param {string} actual
176+
* @param {string} expected
178177
* @return {string} Diff
179178
*/
180179
var generateDiff = exports.generateDiff = function (actual, expected) {
181-
if (exports.inlineDiffs) {
182-
return inlineDiff(actual, expected);
183-
} else {
184-
return unifiedDiff(actual, expected);
185-
}
180+
return exports.inlineDiffs
181+
? inlineDiff(actual, expected)
182+
: unifiedDiff(actual, expected);
186183
};
187184

188185
/**

test/reporters/base.spec.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,31 +137,33 @@ describe('Base reporter', function () {
137137
});
138138

139139
describe('Diff generation', function () {
140+
var oldInlineDiffs;
141+
142+
beforeEach(function () {
143+
oldInlineDiffs = Base.inlineDiffs;
144+
});
145+
146+
afterEach(function () {
147+
Base.inlineDiffs = oldInlineDiffs;
148+
});
149+
140150
it('should generate unified diffs if `inlineDiff === false`', function () {
141151
var actual = 'a foo unified diff';
142152
var expected = 'a bar unified diff';
143153

144-
var oldInlineDiffs = Base.inlineDiffs;
145154
Base.inlineDiffs = false;
146-
147155
var output = Base.generateDiff(actual, expected);
148156

149-
Base.inlineDiffs = oldInlineDiffs;
150-
151157
expect(output).to.equal('\n + expected - actual\n\n -a foo unified diff\n +a bar unified diff\n ');
152158
});
153159

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

158-
var oldInlineDiffs = Base.inlineDiffs;
159164
Base.inlineDiffs = true;
160-
161165
var output = Base.generateDiff(actual, expected);
162166

163-
Base.inlineDiffs = oldInlineDiffs;
164-
165167
expect(output).to.equal(' \n actual expected\n \n a foobar inline diff\n ');
166168
});
167169
});

0 commit comments

Comments
 (0)