Skip to content

Commit f48a032

Browse files
committed
Use the new syntax in the docs.
1 parent 9455fc1 commit f48a032

File tree

3 files changed

+12
-23
lines changed

3 files changed

+12
-23
lines changed

documentation/api/UnexpectedError.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,16 @@ expect.addAssertion("<array> to have item satisfying <any+>", function (expect,
4141
if (failed) {
4242
expect.fail({
4343
diff: function (output, diff, inspect, equal) {
44-
var result = {
45-
inline: true,
46-
diff: output
47-
};
44+
output.inline = true;
4845
promises.forEach(function (promise, index) {
49-
if (index > 0) { result.diff.nl(2); }
46+
if (index > 0) { output.nl(2); }
5047
var error = promise.reason();
5148
// the error is connected to the current scope
5249
// but we are just interested in the nested error
5350
error.errorMode = 'bubble';
54-
result.diff.append(error.getErrorMessage(output));
51+
output.append(error.getErrorMessage(output));
5552
});
56-
return result;
53+
return output;
5754
}
5855
});
5956
}
@@ -156,8 +153,7 @@ expect.addAssertion('<any> to be completely custom', function (expect, subject)
156153
expect.fail({
157154
diff: function (output, diff, inspect, equal) {
158155
output.text('~~~~~~~~~~~~~~').sp().success('custom').sp().text('~~~~~~~~~~~~~~').nl();
159-
var result = createDiff(output, diff, inspect, equal);
160-
return result;
156+
return createDiff(output, diff, inspect, equal);
161157
}
162158
});
163159
});

documentation/api/addType.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,21 @@ expect.addType({
238238
return a === b || equal(a.name, b.name);
239239
},
240240
diff: function (actual, expected, output, diff, inspect) {
241+
output.inline = inlineDiff;
241242
var nameDiff = diff(actual.name, expected.name);
242243
243244
output.text('new Person(')
244245
.nl()
245246
.indentLines();
246247
247248
if (nameDiff && nameDiff.inline) {
248-
output.append(nameDiff.diff);
249+
output.append(nameDiff);
249250
} else {
250251
output.i().append(inspect(actual.name)).text(',').sp()
251252
.annotationBlock(function () {
252253
this.error('should be ').append(inspect(expected.name));
253254
if (nameDiff) {
254-
this.nl().append(nameDiff.diff);
255+
this.nl().append(nameDiff);
255256
}
256257
})
257258
.nl();
@@ -262,10 +263,7 @@ expect.addType({
262263
.nl()
263264
.text(')');
264265
265-
return {
266-
inline: inlineDiff,
267-
diff: output
268-
};
266+
return output;
269267
}
270268
});
271269
```

documentation/api/withError.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ expect.addAssertion('to have same gender as', function (expect, subject, value)
2929
}, function (e) {
3030
expect.fail({
3131
diff: function (output) {
32-
return {
33-
inline: false,
34-
diff: output.bold(subject.genderSign()).text('').bold(value.genderSign())
35-
};
32+
return output.bold(subject.genderSign()).text('').bold(value.genderSign());
3633
}
3734
});
3835
});
@@ -59,10 +56,8 @@ expect.addAssertion('delegating to an asynchronous assertion', function (expect,
5956
}, function (e) {
6057
expect.fail({
6158
diff: function (output) {
62-
return {
63-
inline: true,
64-
diff: output.text('Cool a diff attached to an asynchronous failure!')
65-
};
59+
output.inline = true;
60+
return output.text('Cool a diff attached to an asynchronous failure!');
6661
}
6762
});
6863
});

0 commit comments

Comments
 (0)