Skip to content

Commit 55268ea

Browse files
committed
Reformat all files with prettier 2.2.1
1 parent 2c35d0c commit 55268ea

30 files changed

+916
-937
lines changed

documentation/api/UnexpectedError.md

+75-76
Original file line numberDiff line numberDiff line change
@@ -27,42 +27,42 @@ output.appendErrorMessage(error);
2727
This is useful if you want to combine multiple errors in one assertion:
2828

2929
```js
30-
expect.addAssertion('<array> to have item satisfying <any+>', function (
31-
expect,
32-
subject
33-
) {
34-
const args = Array.prototype.slice.call(arguments, 2);
35-
const promises = subject.map(function (item) {
36-
return expect.promise(function () {
37-
return expect.apply(expect, [item].concat(args));
38-
});
39-
});
40-
41-
return expect.promise.settle(promises).then(function () {
42-
const failed = promises.every(function (promise) {
43-
return promise.isRejected();
30+
expect.addAssertion(
31+
'<array> to have item satisfying <any+>',
32+
function (expect, subject) {
33+
const args = Array.prototype.slice.call(arguments, 2);
34+
const promises = subject.map(function (item) {
35+
return expect.promise(function () {
36+
return expect.apply(expect, [item].concat(args));
37+
});
4438
});
4539

46-
if (failed) {
47-
expect.fail({
48-
diff: function (output, diff, inspect, equal) {
49-
output.inline = true;
50-
promises.forEach(function (promise, index) {
51-
if (index > 0) {
52-
output.nl(2);
53-
}
54-
const error = promise.reason();
55-
// the error is connected to the current scope
56-
// but we are just interested in the nested error
57-
error.errorMode = 'bubble';
58-
output.append(error.getErrorMessage(output));
59-
});
60-
return output;
61-
},
40+
return expect.promise.settle(promises).then(function () {
41+
const failed = promises.every(function (promise) {
42+
return promise.isRejected();
6243
});
63-
}
64-
});
65-
});
44+
45+
if (failed) {
46+
expect.fail({
47+
diff: function (output, diff, inspect, equal) {
48+
output.inline = true;
49+
promises.forEach(function (promise, index) {
50+
if (index > 0) {
51+
output.nl(2);
52+
}
53+
const error = promise.reason();
54+
// the error is connected to the current scope
55+
// but we are just interested in the nested error
56+
error.errorMode = 'bubble';
57+
output.append(error.getErrorMessage(output));
58+
});
59+
return output;
60+
},
61+
});
62+
}
63+
});
64+
}
65+
);
6666
```
6767

6868
When the assertion fails we get the following output:
@@ -99,24 +99,23 @@ We could for example change the error mode for all the errors in the
9999
chain to `nested`:
100100

101101
```js
102-
expect.addAssertion('<any> detailed to be <any>', function (
103-
expect,
104-
subject,
105-
value
106-
) {
107-
expect.errorMode = 'bubble';
108-
expect.withError(
109-
function () {
110-
expect(subject, 'to be', value);
111-
},
112-
function (err) {
113-
err.getParents().forEach(function (e) {
114-
e.errorMode = 'nested';
115-
});
116-
expect.fail(err);
117-
}
118-
);
119-
});
102+
expect.addAssertion(
103+
'<any> detailed to be <any>',
104+
function (expect, subject, value) {
105+
expect.errorMode = 'bubble';
106+
expect.withError(
107+
function () {
108+
expect(subject, 'to be', value);
109+
},
110+
function (err) {
111+
err.getParents().forEach(function (e) {
112+
e.errorMode = 'nested';
113+
});
114+
expect.fail(err);
115+
}
116+
);
117+
}
118+
);
120119

121120
expect('f00!', 'detailed to be', 'foo!');
122121
```
@@ -159,31 +158,31 @@ create the diff. Now you can delegate to that method from
159158
`expect.fail`:
160159

161160
```js
162-
expect.addAssertion('<any> to be completely custom', function (
163-
expect,
164-
subject
165-
) {
166-
return expect.withError(
167-
function () {
168-
expect(subject, 'to satisfy', { custom: true });
169-
},
170-
function (err) {
171-
const createDiff = err.getDiffMethod();
172-
expect.fail({
173-
diff: function (output, diff, inspect, equal) {
174-
output
175-
.text('~~~~~~~~~~~~~~')
176-
.sp()
177-
.success('custom')
178-
.sp()
179-
.text('~~~~~~~~~~~~~~')
180-
.nl();
181-
return createDiff(output, diff, inspect, equal);
182-
},
183-
});
184-
}
185-
);
186-
});
161+
expect.addAssertion(
162+
'<any> to be completely custom',
163+
function (expect, subject) {
164+
return expect.withError(
165+
function () {
166+
expect(subject, 'to satisfy', { custom: true });
167+
},
168+
function (err) {
169+
const createDiff = err.getDiffMethod();
170+
expect.fail({
171+
diff: function (output, diff, inspect, equal) {
172+
output
173+
.text('~~~~~~~~~~~~~~')
174+
.sp()
175+
.success('custom')
176+
.sp()
177+
.text('~~~~~~~~~~~~~~')
178+
.nl();
179+
return createDiff(output, diff, inspect, equal);
180+
},
181+
});
182+
}
183+
);
184+
}
185+
);
187186

188187
expect({ custom: false }, 'to be completely custom');
189188
```

0 commit comments

Comments
 (0)