@serenity-js/assertions 3.0.0-rc.2 → 3.0.0-rc.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +461 -1
- package/README.md +1 -1
- package/lib/Ensure.d.ts +1 -1
- package/lib/Ensure.js +7 -10
- package/lib/Ensure.js.map +1 -1
- package/lib/expectations/and.d.ts +1 -1
- package/lib/expectations/and.js +6 -6
- package/lib/expectations/and.js.map +1 -1
- package/lib/expectations/contain.d.ts +1 -1
- package/lib/expectations/containAtLeastOneItemThat.d.ts +1 -1
- package/lib/expectations/containAtLeastOneItemThat.js +16 -9
- package/lib/expectations/containAtLeastOneItemThat.js.map +1 -1
- package/lib/expectations/containItemsWhereEachItem.d.ts +1 -1
- package/lib/expectations/containItemsWhereEachItem.js +16 -9
- package/lib/expectations/containItemsWhereEachItem.js.map +1 -1
- package/lib/expectations/index.d.ts +1 -1
- package/lib/expectations/index.js +6 -2
- package/lib/expectations/index.js.map +1 -1
- package/lib/expectations/isFalse.js.map +1 -1
- package/lib/expectations/isPresent.d.ts +14 -0
- package/lib/expectations/isPresent.js +50 -0
- package/lib/expectations/isPresent.js.map +1 -0
- package/lib/expectations/isTrue.js.map +1 -1
- package/lib/expectations/matches.d.ts +1 -1
- package/lib/expectations/not.d.ts +1 -1
- package/lib/expectations/not.js +7 -8
- package/lib/expectations/not.js.map +1 -1
- package/lib/expectations/or.d.ts +1 -1
- package/lib/expectations/or.js +17 -12
- package/lib/expectations/or.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/package.json +12 -33
- package/src/Ensure.ts +17 -21
- package/src/expectations/and.ts +19 -18
- package/src/expectations/contain.ts +1 -1
- package/src/expectations/containAtLeastOneItemThat.ts +38 -14
- package/src/expectations/containItemsWhereEachItem.ts +38 -14
- package/src/expectations/index.ts +1 -1
- package/src/expectations/isFalse.ts +1 -1
- package/src/expectations/isPresent.ts +58 -0
- package/src/expectations/isTrue.ts +1 -1
- package/src/expectations/matches.ts +1 -1
- package/src/expectations/not.ts +15 -15
- package/src/expectations/or.ts +28 -25
- package/lib/expectations/property.d.ts +0 -2
- package/lib/expectations/property.js +0 -28
- package/lib/expectations/property.js.map +0 -1
- package/src/expectations/property.ts +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containAtLeastOneItemThat.js","sourceRoot":"","sources":["../../src/expectations/containAtLeastOneItemThat.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"containAtLeastOneItemThat.js","sourceRoot":"","sources":["../../src/expectations/containAtLeastOneItemThat.ts"],"names":[],"mappings":";;;AAAA,4CAAwI;AAExI,SAAgB,yBAAyB,CAAS,WAAgC;IAC9E,OAAO,IAAI,yCAAyC,CAAC,WAAW,CAAC,CAAC;AACtE,CAAC;AAFD,8DAEC;AAED;;GAEG;AACH,MAAM,yCAAkD,SAAQ,kBAAqB;IAMjF,YAA6B,WAAgC;QACzD,KAAK,CACD,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,KAAK,EAAE,KAAuB,EAAE,MAA4B,EAAE,EAAE;YAE5D,MAAM,KAAK,GAAa,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAEnD,IAAI,CAAE,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC/B,OAAO,IAAI,wBAAiB,CACxB,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,SAAS,EACT,KAAK,CACR,CAAC;aACL;YAED,IAAI,OAA4C,CAAC;YAEjD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBAEtB,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;gBAExD,IAAI,OAAO,YAAY,qBAAc,EAAE;oBACnC,OAAO,IAAI,qBAAc,CACrB,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,OAAO,CAAC,QAAQ,EAChB,KAAK,CACR,CAAC;iBACL;aACJ;YAED,OAAO,IAAI,wBAAiB,CAAC,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACjI,CAAC,CACJ,CAAC;QAhCuB,gBAAW,GAAX,WAAW,CAAqB;IAiC7D,CAAC;IArCO,MAAM,CAAC,cAAc,CAAC,WAA6B;QACvD,OAAO,IAAA,QAAC,EAAA,uCAAwC,WAAY,EAAE,CAAC;IACnE,CAAC;CAoCJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Expectation } from '@serenity-js/core';
|
|
2
|
-
export declare function containItemsWhereEachItem<Actual>(expectation: Expectation<
|
|
2
|
+
export declare function containItemsWhereEachItem<Actual>(expectation: Expectation<Actual>): Expectation<Actual[]>;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.containItemsWhereEachItem = void 0;
|
|
4
4
|
const core_1 = require("@serenity-js/core");
|
|
5
|
-
const io_1 = require("@serenity-js/core/lib/io");
|
|
6
5
|
function containItemsWhereEachItem(expectation) {
|
|
7
6
|
return new ContainItemsWhereEachItemMeetsExpectation(expectation);
|
|
8
7
|
}
|
|
@@ -12,16 +11,24 @@ exports.containItemsWhereEachItem = containItemsWhereEachItem;
|
|
|
12
11
|
*/
|
|
13
12
|
class ContainItemsWhereEachItemMeetsExpectation extends core_1.Expectation {
|
|
14
13
|
constructor(expectation) {
|
|
15
|
-
super((
|
|
14
|
+
super(ContainItemsWhereEachItemMeetsExpectation.descriptionFor(expectation), async (actor, actual) => {
|
|
15
|
+
const items = await actor.answer(actual);
|
|
16
|
+
if (!items || items.length === 0) {
|
|
17
|
+
return new core_1.ExpectationNotMet(ContainItemsWhereEachItemMeetsExpectation.descriptionFor(expectation), undefined, items);
|
|
18
|
+
}
|
|
19
|
+
let outcome;
|
|
20
|
+
for (const item of items) {
|
|
21
|
+
outcome = await actor.answer(expectation.isMetFor(item));
|
|
22
|
+
if (outcome instanceof core_1.ExpectationNotMet) {
|
|
23
|
+
return new core_1.ExpectationNotMet(ContainItemsWhereEachItemMeetsExpectation.descriptionFor(expectation), outcome.expected, items);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return new core_1.ExpectationMet(ContainItemsWhereEachItemMeetsExpectation.descriptionFor(expectation), outcome.expected, items);
|
|
27
|
+
});
|
|
16
28
|
this.expectation = expectation;
|
|
17
29
|
}
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
? Promise.resolve(new core_1.ExpectationNotMet(this.toString(), undefined, actual))
|
|
21
|
-
: Promise.all(actual.map(item => this.expectation.answeredBy(actor)(item)))
|
|
22
|
-
.then(results => results.every(result => result instanceof core_1.ExpectationMet)
|
|
23
|
-
? new core_1.ExpectationMet(this.toString(), results[0].expected, actual)
|
|
24
|
-
: new core_1.ExpectationNotMet(this.toString(), results[0].expected, actual));
|
|
30
|
+
static descriptionFor(expectation) {
|
|
31
|
+
return (0, core_1.d) `contain items where each item does ${expectation}`;
|
|
25
32
|
}
|
|
26
33
|
}
|
|
27
34
|
//# sourceMappingURL=containItemsWhereEachItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containItemsWhereEachItem.js","sourceRoot":"","sources":["../../src/expectations/containItemsWhereEachItem.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"containItemsWhereEachItem.js","sourceRoot":"","sources":["../../src/expectations/containItemsWhereEachItem.ts"],"names":[],"mappings":";;;AAAA,4CAAwI;AAExI,SAAgB,yBAAyB,CAAS,WAAgC;IAC9E,OAAO,IAAI,yCAAyC,CAAC,WAAW,CAAC,CAAC;AACtE,CAAC;AAFD,8DAEC;AAED;;GAEG;AACH,MAAM,yCAAkD,SAAQ,kBAAqB;IAMjF,YAA6B,WAAgC;QACzD,KAAK,CACD,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,KAAK,EAAE,KAAuB,EAAE,MAA4B,EAAE,EAAE;YAE5D,MAAM,KAAK,GAAa,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAEnD,IAAI,CAAE,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC/B,OAAO,IAAI,wBAAiB,CACxB,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,SAAS,EACT,KAAK,CACR,CAAC;aACL;YAED,IAAI,OAA4C,CAAC;YAEjD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBAEtB,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;gBAExD,IAAI,OAAO,YAAY,wBAAiB,EAAE;oBACtC,OAAO,IAAI,wBAAiB,CACxB,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,OAAO,CAAC,QAAQ,EAChB,KAAK,CACR,CAAC;iBACL;aACJ;YAED,OAAO,IAAI,qBAAc,CAAC,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC9H,CAAC,CACJ,CAAC;QAhCuB,gBAAW,GAAX,WAAW,CAAqB;IAiC7D,CAAC;IArCO,MAAM,CAAC,cAAc,CAAC,WAA6B;QACvD,OAAO,IAAA,QAAC,EAAA,sCAAuC,WAAY,EAAE,CAAC;IAClE,CAAC;CAoCJ"}
|
|
@@ -10,9 +10,9 @@ export * from './isBefore';
|
|
|
10
10
|
export * from './isFalse';
|
|
11
11
|
export * from './isGreaterThan';
|
|
12
12
|
export * from './isLessThan';
|
|
13
|
+
export * from './isPresent';
|
|
13
14
|
export * from './isTrue';
|
|
14
15
|
export * from './matches';
|
|
15
16
|
export * from './not';
|
|
16
17
|
export * from './or';
|
|
17
|
-
export * from './property';
|
|
18
18
|
export * from './startsWith';
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -22,10 +26,10 @@ __exportStar(require("./isBefore"), exports);
|
|
|
22
26
|
__exportStar(require("./isFalse"), exports);
|
|
23
27
|
__exportStar(require("./isGreaterThan"), exports);
|
|
24
28
|
__exportStar(require("./isLessThan"), exports);
|
|
29
|
+
__exportStar(require("./isPresent"), exports);
|
|
25
30
|
__exportStar(require("./isTrue"), exports);
|
|
26
31
|
__exportStar(require("./matches"), exports);
|
|
27
32
|
__exportStar(require("./not"), exports);
|
|
28
33
|
__exportStar(require("./or"), exports);
|
|
29
|
-
__exportStar(require("./property"), exports);
|
|
30
34
|
__exportStar(require("./startsWith"), exports);
|
|
31
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/expectations/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/expectations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,4CAA0B;AAC1B,8DAA4C;AAC5C,8DAA4C;AAC5C,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,kDAAgC;AAChC,+CAA6B;AAC7B,8CAA4B;AAC5B,2CAAyB;AACzB,4CAA0B;AAC1B,wCAAsB;AACtB,uCAAqB;AACrB,+CAA6B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFalse.js","sourceRoot":"","sources":["../../src/expectations/isFalse.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD,qCAAkC;AAElC,SAAgB,OAAO;IACnB,OAAO,kBAAW,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"isFalse.js","sourceRoot":"","sources":["../../src/expectations/isFalse.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD,qCAAkC;AAElC,SAAgB,OAAO;IACnB,OAAO,kBAAW,CAAC,EAAE,CAAiB,aAAa,CAAC,CAAC,YAAY,CAAC,IAAA,eAAM,EAAC,KAAK,CAAC,CAAC,CAAC;AACrF,CAAC;AAFD,0BAEC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Expectation } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* @desc
|
|
4
|
+
* Expectation that the `actual` is not undefined or null.
|
|
5
|
+
* Also, for `actual` implementing {@link @serenity-js/core/lib/screenplay~Optional}, that `Optional.isPresent()` returns an {@link @serenity-js/core/lib/screenplay~Answerable}
|
|
6
|
+
* that resolves to `true`
|
|
7
|
+
*
|
|
8
|
+
* @returns {@serenity-js/core/lib/screenplay/questions~Expectation<Answerable<boolean>, Optional>}
|
|
9
|
+
*
|
|
10
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
11
|
+
* @see {@link @serenity-js/core/lib/screenplay/questions~Check}
|
|
12
|
+
* @see {@link @serenity-js/core/lib/screenplay/interactions~Wait}
|
|
13
|
+
*/
|
|
14
|
+
export declare function isPresent<Actual>(): Expectation<Actual>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPresent = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
/**
|
|
6
|
+
* @desc
|
|
7
|
+
* Expectation that the `actual` is not undefined or null.
|
|
8
|
+
* Also, for `actual` implementing {@link @serenity-js/core/lib/screenplay~Optional}, that `Optional.isPresent()` returns an {@link @serenity-js/core/lib/screenplay~Answerable}
|
|
9
|
+
* that resolves to `true`
|
|
10
|
+
*
|
|
11
|
+
* @returns {@serenity-js/core/lib/screenplay/questions~Expectation<Answerable<boolean>, Optional>}
|
|
12
|
+
*
|
|
13
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
14
|
+
* @see {@link @serenity-js/core/lib/screenplay/questions~Check}
|
|
15
|
+
* @see {@link @serenity-js/core/lib/screenplay/interactions~Wait}
|
|
16
|
+
*/
|
|
17
|
+
function isPresent() {
|
|
18
|
+
return new IsPresent();
|
|
19
|
+
}
|
|
20
|
+
exports.isPresent = isPresent;
|
|
21
|
+
class IsPresent extends core_1.Expectation {
|
|
22
|
+
static isOptional(value) {
|
|
23
|
+
return value !== undefined
|
|
24
|
+
&& value !== null
|
|
25
|
+
&& typeof value.isPresent === 'function';
|
|
26
|
+
}
|
|
27
|
+
static valueToCheck(actual, actor) {
|
|
28
|
+
if (IsPresent.isOptional(actual)) {
|
|
29
|
+
return actual;
|
|
30
|
+
}
|
|
31
|
+
return actor.answer(actual);
|
|
32
|
+
}
|
|
33
|
+
static async isPresent(value, actor) {
|
|
34
|
+
if (IsPresent.isOptional(value)) {
|
|
35
|
+
return actor.answer(value.isPresent());
|
|
36
|
+
}
|
|
37
|
+
return value !== undefined
|
|
38
|
+
&& value !== null;
|
|
39
|
+
}
|
|
40
|
+
constructor() {
|
|
41
|
+
super('become present', async (actor, actual) => {
|
|
42
|
+
const value = await IsPresent.valueToCheck(actual, actor);
|
|
43
|
+
const result = await IsPresent.isPresent(value, actor);
|
|
44
|
+
return result
|
|
45
|
+
? new core_1.ExpectationMet('become present', undefined, undefined)
|
|
46
|
+
: new core_1.ExpectationNotMet('become present', undefined, undefined);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=isPresent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPresent.js","sourceRoot":"","sources":["../../src/expectations/isPresent.ts"],"names":[],"mappings":";;;AAAA,4CAA2H;AAE3H;;;;;;;;;;;GAWG;AACH,SAAgB,SAAS;IACrB,OAAO,IAAI,SAAS,EAAU,CAAC;AACnC,CAAC;AAFD,8BAEC;AAED,MAAM,SAAkB,SAAQ,kBAAmB;IACvC,MAAM,CAAC,UAAU,CAAC,KAAU;QAChC,OAAO,KAAK,KAAK,SAAS;eACnB,KAAK,KAAK,IAAI;eACd,OAAO,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC;IACjD,CAAC;IAEO,MAAM,CAAC,YAAY,CAAI,MAAqB,EAAE,KAAuB;QACzE,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;YAC9B,OAAO,MAAM,CAAC;SACjB;QAED,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAI,KAAoB,EAAE,KAAuB;QAC3E,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;SAC1C;QAED,OAAO,KAAK,KAAK,SAAS;eACnB,KAAK,KAAK,IAAI,CAAC;IAC1B,CAAC;IAED;QACI,KAAK,CACD,gBAAgB,EAChB,KAAK,EAAE,KAAuB,EAAE,MAA0B,EAAE,EAAE;YAE1D,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YAE1D,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAEvD,OAAO,MAAM;gBACT,CAAC,CAAC,IAAI,qBAAc,CAAC,gBAAgB,EAAE,SAAS,EAAE,SAAS,CAAC;gBAC5D,CAAC,CAAC,IAAI,wBAAiB,CAAC,gBAAgB,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QACxE,CAAC,CACJ,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isTrue.js","sourceRoot":"","sources":["../../src/expectations/isTrue.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD,qCAAkC;AAElC,SAAgB,MAAM;IAClB,OAAO,kBAAW,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"isTrue.js","sourceRoot":"","sources":["../../src/expectations/isTrue.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD,qCAAkC;AAElC,SAAgB,MAAM;IAClB,OAAO,kBAAW,CAAC,EAAE,CAAiB,YAAY,CAAC,CAAC,YAAY,CAAC,IAAA,eAAM,EAAC,IAAI,CAAC,CAAC,CAAC;AACnF,CAAC;AAFD,wBAEC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Answerable, Expectation } from '@serenity-js/core';
|
|
2
|
-
export declare function matches(expected: Answerable<RegExp>): Expectation<
|
|
2
|
+
export declare function matches(expected: Answerable<RegExp>): Expectation<string>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Expectation } from '@serenity-js/core';
|
|
2
|
-
export declare function not<
|
|
2
|
+
export declare function not<Actual>(assertion: Expectation<Actual>): Expectation<Actual>;
|
package/lib/expectations/not.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.not = void 0;
|
|
4
4
|
const core_1 = require("@serenity-js/core");
|
|
5
|
-
const tiny_types_1 = require("tiny-types");
|
|
6
5
|
function not(assertion) {
|
|
7
6
|
return new Not(assertion);
|
|
8
7
|
}
|
|
@@ -12,7 +11,13 @@ exports.not = not;
|
|
|
12
11
|
*/
|
|
13
12
|
class Not extends core_1.Expectation {
|
|
14
13
|
constructor(expectation) {
|
|
15
|
-
super(Not.flipped(expectation.toString()))
|
|
14
|
+
super(Not.flipped(expectation.toString()), async (actor, actual) => {
|
|
15
|
+
const subject = Not.flipped(expectation.toString());
|
|
16
|
+
const outcome = await actor.answer(expectation.isMetFor(actual));
|
|
17
|
+
return outcome instanceof core_1.ExpectationNotMet
|
|
18
|
+
? new core_1.ExpectationMet(subject, outcome.expected, outcome.actual)
|
|
19
|
+
: new core_1.ExpectationNotMet(subject, outcome.expected, outcome.actual);
|
|
20
|
+
});
|
|
16
21
|
this.expectation = expectation;
|
|
17
22
|
}
|
|
18
23
|
static flipped(message) {
|
|
@@ -20,11 +25,5 @@ class Not extends core_1.Expectation {
|
|
|
20
25
|
? message.slice(4)
|
|
21
26
|
: `not ${message}`;
|
|
22
27
|
}
|
|
23
|
-
answeredBy(actor) {
|
|
24
|
-
return (actual) => this.expectation.answeredBy(actor)(actual)
|
|
25
|
-
.then((outcome) => (0, tiny_types_1.match)(outcome)
|
|
26
|
-
.when(core_1.ExpectationMet, o => new core_1.ExpectationNotMet(this.subject, o.expected, o.actual))
|
|
27
|
-
.else(o => new core_1.ExpectationMet(this.subject, o.expected, o.actual)));
|
|
28
|
-
}
|
|
29
28
|
}
|
|
30
29
|
//# sourceMappingURL=not.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not.js","sourceRoot":"","sources":["../../src/expectations/not.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"not.js","sourceRoot":"","sources":["../../src/expectations/not.ts"],"names":[],"mappings":";;;AAAA,4CAAiH;AAEjH,SAAgB,GAAG,CAAS,SAA8B;IACtD,OAAO,IAAI,GAAG,CAAS,SAAS,CAAC,CAAC;AACtC,CAAC;AAFD,kBAEC;AAED;;GAEG;AACH,MAAM,GAAY,SAAQ,kBAAmB;IAOzC,YAA6B,WAAgC;QACzD,KAAK,CACD,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,EACnC,KAAK,EAAE,KAAuB,EAAE,MAA0B,EAAE,EAAE;YAC1D,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEpD,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAEjE,OAAO,OAAO,YAAY,wBAAiB;gBACvC,CAAC,CAAC,IAAI,qBAAc,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC;gBAC/D,CAAC,CAAC,IAAI,wBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3E,CAAC,CACJ,CAAC;QAZuB,gBAAW,GAAX,WAAW,CAAqB;IAa7D,CAAC;IAnBO,MAAM,CAAC,OAAO,CAAC,OAAe;QAClC,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;YAC7B,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,OAAQ,OAAQ,EAAE,CAAC;IAC7B,CAAC;CAgBJ"}
|
package/lib/expectations/or.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Expectation } from '@serenity-js/core';
|
|
2
|
-
export declare function or<Actual>(...assertions: Array<Expectation<
|
|
2
|
+
export declare function or<Actual>(...assertions: Array<Expectation<Actual>>): Expectation<Actual>;
|
package/lib/expectations/or.js
CHANGED
|
@@ -11,20 +11,25 @@ exports.or = or;
|
|
|
11
11
|
*/
|
|
12
12
|
class Or extends core_1.Expectation {
|
|
13
13
|
constructor(expectations) {
|
|
14
|
-
super(expectations
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
super(Or.descriptionFor(expectations), async (actor, actual) => {
|
|
15
|
+
if (!expectations || expectations.length === 0) {
|
|
16
|
+
throw new core_1.LogicError(`No expectations provided to or()`);
|
|
17
|
+
}
|
|
18
|
+
let outcome;
|
|
19
|
+
for (const expectation of expectations) {
|
|
20
|
+
outcome = await actor.answer(expectation.isMetFor(actual));
|
|
21
|
+
if (outcome instanceof core_1.ExpectationMet) {
|
|
22
|
+
return outcome;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return new core_1.ExpectationNotMet(Or.descriptionFor(expectations), outcome.expected, outcome.actual);
|
|
26
|
+
});
|
|
17
27
|
this.expectations = expectations;
|
|
18
28
|
}
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
.
|
|
22
|
-
|
|
23
|
-
const unmetExpectations = outcomes.filter(outcome => outcome instanceof core_1.ExpectationNotMet), message = outcomes.map(outcome => outcome.message).join(Or.Separator);
|
|
24
|
-
return unmetExpectations.length === this.expectations.length
|
|
25
|
-
? new core_1.ExpectationNotMet(message, outcomes[0].expected, outcomes[0].actual)
|
|
26
|
-
: new core_1.ExpectationMet(message, outcomes[0].expected, outcomes[0].actual);
|
|
27
|
-
});
|
|
29
|
+
static descriptionFor(expectations) {
|
|
30
|
+
return expectations
|
|
31
|
+
.map(expectation => expectation.toString())
|
|
32
|
+
.join(Or.Separator);
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
35
|
Or.Separator = ' or ';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"or.js","sourceRoot":"","sources":["../../src/expectations/or.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"or.js","sourceRoot":"","sources":["../../src/expectations/or.ts"],"names":[],"mappings":";;;AAAA,4CAAiJ;AAEjJ,SAAgB,EAAE,CAAS,GAAG,UAAsC;IAChE,OAAO,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC;AAFD,gBAEC;AAED;;GAEG;AACH,MAAM,EAAW,SAAQ,kBAAmB;IASxC,YAA6B,YAAwC;QACjE,KAAK,CACD,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,EAC/B,KAAK,EAAE,KAAuB,EAAE,MAA0B,EAAE,EAAE;YAC1D,IAAI,CAAE,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC7C,MAAM,IAAI,iBAAU,CAAC,kCAAkC,CAAC,CAAC;aAC5D;YAED,IAAI,OAA4C,CAAC;YACjD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;gBACpC,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;gBAE3D,IAAI,OAAO,YAAY,qBAAc,EAAE;oBACnC,OAAO,OAAO,CAAC;iBAClB;aACJ;YAED,OAAO,IAAI,wBAAiB,CACxB,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,EAC/B,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,MAAM,CACjB,CAAC;QACN,CAAC,CACJ,CAAC;QAvBuB,iBAAY,GAAZ,YAAY,CAA4B;IAwBrE,CAAC;IA9BO,MAAM,CAAC,cAAc,CAAI,YAAmC;QAChE,OAAO,YAAY;aACd,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;aAC1C,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;;AANuB,YAAS,GAAG,MAAM,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,iDAA+B;AAC/B,0CAAuD,CAAC,gFAAgF;AAA/H,6FAAA,KAAK,OAAA;AAAE,mGAAA,WAAW,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/assertions",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.20",
|
|
4
4
|
"description": "Screenplay-style assertion library",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -29,13 +29,14 @@
|
|
|
29
29
|
"clean": "rimraf .nyc_output lib target",
|
|
30
30
|
"lint": "eslint --ext ts --config ../../.eslintrc.yml .",
|
|
31
31
|
"lint:fix": "npm run lint -- --fix",
|
|
32
|
-
"test": "nyc
|
|
32
|
+
"test": "nyc mocha --config ../../.mocharc.yml 'spec/**/*.spec.*'",
|
|
33
33
|
"compile": "tsc --project tsconfig.json",
|
|
34
34
|
"site": "esdoc -c .esdoc.js"
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|
|
38
|
-
"url": "https://github.com/serenity-js/serenity-js.git"
|
|
38
|
+
"url": "https://github.com/serenity-js/serenity-js.git",
|
|
39
|
+
"directory": "packages/assertions"
|
|
39
40
|
},
|
|
40
41
|
"bugs": {
|
|
41
42
|
"url": "https://github.com/serenity-js/serenity-js/issues"
|
|
@@ -45,39 +46,17 @@
|
|
|
45
46
|
"npm": "^6 || ^7 || ^8"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"@serenity-js/core": "3.0.0-rc.
|
|
49
|
-
"tiny-types": "^1.
|
|
49
|
+
"@serenity-js/core": "3.0.0-rc.20",
|
|
50
|
+
"tiny-types": "^1.18.4"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@documentation/esdoc-template": "3.0.0",
|
|
53
54
|
"@integration/testing-tools": "3.0.0",
|
|
54
|
-
"@types/chai": "^4.3.
|
|
55
|
-
"@types/mocha": "^9.
|
|
56
|
-
"mocha": "^
|
|
57
|
-
"ts-node": "
|
|
58
|
-
"typescript": "^4.
|
|
55
|
+
"@types/chai": "^4.3.1",
|
|
56
|
+
"@types/mocha": "^9.1.1",
|
|
57
|
+
"mocha": "^10.0.0",
|
|
58
|
+
"ts-node": "10.8.0",
|
|
59
|
+
"typescript": "^4.7.4"
|
|
59
60
|
},
|
|
60
|
-
"
|
|
61
|
-
"include": [
|
|
62
|
-
"src/**/*.ts"
|
|
63
|
-
],
|
|
64
|
-
"exclude": [
|
|
65
|
-
"src/**/*.d.ts",
|
|
66
|
-
"lib",
|
|
67
|
-
"node_modules",
|
|
68
|
-
"spec"
|
|
69
|
-
],
|
|
70
|
-
"extension": [
|
|
71
|
-
".ts"
|
|
72
|
-
],
|
|
73
|
-
"require": [
|
|
74
|
-
"ts-node/register"
|
|
75
|
-
],
|
|
76
|
-
"reporter": [
|
|
77
|
-
"json"
|
|
78
|
-
],
|
|
79
|
-
"cache": true,
|
|
80
|
-
"all": true
|
|
81
|
-
},
|
|
82
|
-
"gitHead": "944ff400a3766e75980aea5d3b401d8acca7c6d8"
|
|
61
|
+
"gitHead": "105a84c6ab140c06e38d328274473a32b290080d"
|
|
83
62
|
}
|
package/src/Ensure.ts
CHANGED
|
@@ -3,16 +3,17 @@ import {
|
|
|
3
3
|
AnswersQuestions,
|
|
4
4
|
AssertionError,
|
|
5
5
|
CollectsArtifacts,
|
|
6
|
+
d,
|
|
6
7
|
Expectation,
|
|
7
8
|
ExpectationMet,
|
|
8
9
|
ExpectationNotMet,
|
|
9
10
|
ExpectationOutcome,
|
|
11
|
+
f,
|
|
10
12
|
Interaction,
|
|
11
13
|
LogicError,
|
|
12
14
|
RuntimeError,
|
|
13
15
|
UsesAbilities,
|
|
14
16
|
} from '@serenity-js/core';
|
|
15
|
-
import { formatted } from '@serenity-js/core/lib/io';
|
|
16
17
|
import { inspected } from '@serenity-js/core/lib/io/inspected';
|
|
17
18
|
import { Artifact, AssertionReport, Name } from '@serenity-js/core/lib/model';
|
|
18
19
|
import { match } from 'tiny-types';
|
|
@@ -68,7 +69,7 @@ export class Ensure<Actual> extends Interaction {
|
|
|
68
69
|
*
|
|
69
70
|
* @returns {Ensure<A>}
|
|
70
71
|
*/
|
|
71
|
-
static that<A>(actual: Answerable<A>, expectation: Expectation<
|
|
72
|
+
static that<A>(actual: Answerable<A>, expectation: Expectation<A>): Ensure<A> {
|
|
72
73
|
return new Ensure(actual, expectation);
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -96,24 +97,19 @@ export class Ensure<Actual> extends Interaction {
|
|
|
96
97
|
* @see {@link @serenity-js/core/lib/screenplay/actor~CollectsArtifacts}
|
|
97
98
|
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
98
99
|
*/
|
|
99
|
-
performAs(actor: UsesAbilities & AnswersQuestions & CollectsArtifacts): Promise<void> {
|
|
100
|
-
|
|
101
|
-
actor.answer(this.actual),
|
|
102
|
-
actor.answer(this.expectation),
|
|
103
|
-
]).then(([ actual, expectation ]) =>
|
|
104
|
-
expectation(actual).then(outcome =>
|
|
105
|
-
match<ExpectationOutcome<unknown, Actual>, void>(outcome)
|
|
106
|
-
.when(ExpectationNotMet, o => {
|
|
107
|
-
actor.collect(this.artifactFrom(o.expected, o.actual), new Name(`Assertion Report`));
|
|
100
|
+
async performAs(actor: UsesAbilities & AnswersQuestions & CollectsArtifacts): Promise<void> {
|
|
101
|
+
const outcome = await actor.answer(this.expectation.isMetFor(this.actual));
|
|
108
102
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
)
|
|
116
|
-
|
|
103
|
+
return match<ExpectationOutcome<unknown, Actual>, void>(outcome)
|
|
104
|
+
.when(ExpectationNotMet, o => {
|
|
105
|
+
actor.collect(this.artifactFrom(o.expected, o.actual), new Name(`Assertion Report`));
|
|
106
|
+
|
|
107
|
+
throw this.errorForOutcome(o);
|
|
108
|
+
})
|
|
109
|
+
.when(ExpectationMet, _ => void 0)
|
|
110
|
+
.else(o => {
|
|
111
|
+
throw new LogicError(f`Expectation#isMetFor(actual) should return an instance of an ExpectationOutcome, not ${ o }`);
|
|
112
|
+
});
|
|
117
113
|
}
|
|
118
114
|
|
|
119
115
|
/**
|
|
@@ -123,7 +119,7 @@ export class Ensure<Actual> extends Interaction {
|
|
|
123
119
|
* @returns {string}
|
|
124
120
|
*/
|
|
125
121
|
toString(): string {
|
|
126
|
-
return
|
|
122
|
+
return d`#actor ensures that ${ this.actual } does ${ this.expectation }`;
|
|
127
123
|
}
|
|
128
124
|
|
|
129
125
|
/**
|
|
@@ -167,7 +163,7 @@ export class Ensure<Actual> extends Interaction {
|
|
|
167
163
|
*/
|
|
168
164
|
protected asAssertionError(outcome: ExpectationOutcome<any, Actual>): AssertionError {
|
|
169
165
|
return new AssertionError(
|
|
170
|
-
`Expected ${
|
|
166
|
+
`Expected ${ d`${ this.actual }` } to ${ outcome.message }`,
|
|
171
167
|
outcome.expected,
|
|
172
168
|
outcome.actual,
|
|
173
169
|
);
|
package/src/expectations/and.ts
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { AnswersQuestions, Expectation, ExpectationNotMet
|
|
1
|
+
import { Answerable, AnswersQuestions, Expectation, ExpectationNotMet } from '@serenity-js/core';
|
|
2
2
|
import { match } from 'tiny-types';
|
|
3
3
|
|
|
4
|
-
export function and<Actual>(...expectations: Array<Expectation<
|
|
4
|
+
export function and<Actual>(...expectations: Array<Expectation<Actual>>): Expectation<Actual> {
|
|
5
5
|
return new And(expectations);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @package
|
|
10
10
|
*/
|
|
11
|
-
class And<Actual> extends Expectation<
|
|
12
|
-
|
|
13
|
-
super(expectations.map(assertion => assertion.toString()).join(' and '));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
answeredBy(actor: AnswersQuestions): (actual: Actual) => Promise<ExpectationOutcome<any, Actual>> {
|
|
11
|
+
class And<Actual> extends Expectation<Actual> {
|
|
12
|
+
private static readonly Separator = ' and ';
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
constructor(private readonly expectations: Array<Expectation<Actual>>) {
|
|
15
|
+
super(
|
|
16
|
+
expectations.map(expectation => expectation.toString()).join(And.Separator),
|
|
17
|
+
(actor: AnswersQuestions, actual: Answerable<Actual>) => {
|
|
18
|
+
return expectations.reduce(
|
|
19
|
+
(previous, current) =>
|
|
20
|
+
previous.then(outcome =>
|
|
21
|
+
match(outcome)
|
|
22
|
+
.when(ExpectationNotMet, o => o)
|
|
23
|
+
.else(_ => actor.answer(current.isMetFor(actual))),
|
|
24
|
+
),
|
|
25
|
+
Promise.resolve(void 0),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Answerable, Expectation } from '@serenity-js/core';
|
|
2
2
|
import { equal } from 'tiny-types/lib/objects';
|
|
3
3
|
|
|
4
|
-
export function contain<Item>(expected: Answerable<Item>): Expectation<Item
|
|
4
|
+
export function contain<Item>(expected: Answerable<Item>): Expectation<Item[]> {
|
|
5
5
|
return Expectation.thatActualShould<Item, Item[]>('contain', expected)
|
|
6
6
|
.soThat((actualValue, expectedValue) => !! ~ actualValue.findIndex(av => equal(av, expectedValue)));
|
|
7
7
|
}
|
|
@@ -1,26 +1,50 @@
|
|
|
1
|
-
import { AnswersQuestions, Expectation, ExpectationMet, ExpectationNotMet, ExpectationOutcome } from '@serenity-js/core';
|
|
2
|
-
import { formatted } from '@serenity-js/core/lib/io';
|
|
1
|
+
import { Answerable, AnswersQuestions, d, Expectation, ExpectationMet, ExpectationNotMet, ExpectationOutcome } from '@serenity-js/core';
|
|
3
2
|
|
|
4
|
-
export function containAtLeastOneItemThat<Actual>(expectation: Expectation<
|
|
3
|
+
export function containAtLeastOneItemThat<Actual>(expectation: Expectation<Actual>): Expectation<Actual[]> {
|
|
5
4
|
return new ContainAtLeastOneItemThatMeetsExpectation(expectation);
|
|
6
5
|
}
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* @package
|
|
10
9
|
*/
|
|
11
|
-
class ContainAtLeastOneItemThatMeetsExpectation<
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
class ContainAtLeastOneItemThatMeetsExpectation<Actual> extends Expectation<Actual[]> {
|
|
11
|
+
|
|
12
|
+
private static descriptionFor(expectation: Expectation<any>) {
|
|
13
|
+
return d`contain at least one item that does ${ expectation }`;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
constructor(private readonly expectation: Expectation<Actual>) {
|
|
17
|
+
super(
|
|
18
|
+
ContainAtLeastOneItemThatMeetsExpectation.descriptionFor(expectation),
|
|
19
|
+
async (actor: AnswersQuestions, actual: Answerable<Actual[]>) => {
|
|
20
|
+
|
|
21
|
+
const items: Actual[] = await actor.answer(actual);
|
|
22
|
+
|
|
23
|
+
if (! items || items.length === 0) {
|
|
24
|
+
return new ExpectationNotMet(
|
|
25
|
+
ContainAtLeastOneItemThatMeetsExpectation.descriptionFor(expectation),
|
|
26
|
+
undefined,
|
|
27
|
+
items,
|
|
24
28
|
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let outcome: ExpectationOutcome<unknown, Actual>;
|
|
32
|
+
|
|
33
|
+
for (const item of items) {
|
|
34
|
+
|
|
35
|
+
outcome = await actor.answer(expectation.isMetFor(item))
|
|
36
|
+
|
|
37
|
+
if (outcome instanceof ExpectationMet) {
|
|
38
|
+
return new ExpectationMet(
|
|
39
|
+
ContainAtLeastOneItemThatMeetsExpectation.descriptionFor(expectation),
|
|
40
|
+
outcome.expected,
|
|
41
|
+
items
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return new ExpectationNotMet(ContainAtLeastOneItemThatMeetsExpectation.descriptionFor(expectation), outcome.expected, items);
|
|
47
|
+
}
|
|
48
|
+
);
|
|
25
49
|
}
|
|
26
50
|
}
|