@serenity-js/assertions 3.41.2 → 3.42.0
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 +12 -0
- package/esm/Ensure.d.ts +110 -0
- package/esm/Ensure.d.ts.map +1 -0
- package/esm/Ensure.js +148 -0
- package/esm/Ensure.js.map +1 -0
- package/esm/EnsureEventually.d.ts +98 -0
- package/esm/EnsureEventually.d.ts.map +1 -0
- package/esm/EnsureEventually.js +142 -0
- package/esm/EnsureEventually.js.map +1 -0
- package/esm/expectations/and.d.ts +23 -0
- package/esm/expectations/and.d.ts.map +1 -0
- package/esm/expectations/and.js +46 -0
- package/esm/expectations/and.js.map +1 -0
- package/esm/expectations/contain.d.ts +27 -0
- package/esm/expectations/contain.d.ts.map +1 -0
- package/esm/expectations/contain.js +28 -0
- package/esm/expectations/contain.js.map +1 -0
- package/esm/expectations/containAtLeastOneItemThat.d.ts +24 -0
- package/esm/expectations/containAtLeastOneItemThat.d.ts.map +1 -0
- package/esm/expectations/containAtLeastOneItemThat.js +53 -0
- package/esm/expectations/containAtLeastOneItemThat.js.map +1 -0
- package/esm/expectations/containItemsWhereEachItem.d.ts +24 -0
- package/esm/expectations/containItemsWhereEachItem.d.ts.map +1 -0
- package/esm/expectations/containItemsWhereEachItem.js +53 -0
- package/esm/expectations/containItemsWhereEachItem.js.map +1 -0
- package/esm/expectations/endsWith.d.ts +22 -0
- package/esm/expectations/endsWith.d.ts.map +1 -0
- package/esm/expectations/endsWith.js +22 -0
- package/esm/expectations/endsWith.js.map +1 -0
- package/esm/expectations/equals.d.ts +28 -0
- package/esm/expectations/equals.d.ts.map +1 -0
- package/esm/expectations/equals.js +29 -0
- package/esm/expectations/equals.js.map +1 -0
- package/esm/expectations/includes.d.ts +41 -0
- package/esm/expectations/includes.d.ts.map +1 -0
- package/esm/expectations/includes.js +41 -0
- package/esm/expectations/includes.js.map +1 -0
- package/esm/expectations/index.d.ts +21 -0
- package/esm/expectations/index.d.ts.map +1 -0
- package/esm/expectations/index.js +21 -0
- package/esm/expectations/index.js.map +1 -0
- package/esm/expectations/isAfter.d.ts +42 -0
- package/esm/expectations/isAfter.d.ts.map +1 -0
- package/esm/expectations/isAfter.js +50 -0
- package/esm/expectations/isAfter.js.map +1 -0
- package/esm/expectations/isBefore.d.ts +42 -0
- package/esm/expectations/isBefore.d.ts.map +1 -0
- package/esm/expectations/isBefore.js +50 -0
- package/esm/expectations/isBefore.js.map +1 -0
- package/esm/expectations/isCloseTo.d.ts +24 -0
- package/esm/expectations/isCloseTo.d.ts.map +1 -0
- package/esm/expectations/isCloseTo.js +34 -0
- package/esm/expectations/isCloseTo.js.map +1 -0
- package/esm/expectations/isFalse.d.ts +21 -0
- package/esm/expectations/isFalse.d.ts.map +1 -0
- package/esm/expectations/isFalse.js +24 -0
- package/esm/expectations/isFalse.js.map +1 -0
- package/esm/expectations/isGreaterThan.d.ts +45 -0
- package/esm/expectations/isGreaterThan.d.ts.map +1 -0
- package/esm/expectations/isGreaterThan.js +45 -0
- package/esm/expectations/isGreaterThan.js.map +1 -0
- package/esm/expectations/isLessThan.d.ts +45 -0
- package/esm/expectations/isLessThan.d.ts.map +1 -0
- package/esm/expectations/isLessThan.js +45 -0
- package/esm/expectations/isLessThan.js.map +1 -0
- package/esm/expectations/isPresent.d.ts +65 -0
- package/esm/expectations/isPresent.d.ts.map +1 -0
- package/esm/expectations/isPresent.js +96 -0
- package/esm/expectations/isPresent.js.map +1 -0
- package/esm/expectations/isTrue.d.ts +21 -0
- package/esm/expectations/isTrue.d.ts.map +1 -0
- package/esm/expectations/isTrue.js +24 -0
- package/esm/expectations/isTrue.js.map +1 -0
- package/esm/expectations/matches.d.ts +22 -0
- package/esm/expectations/matches.d.ts.map +1 -0
- package/esm/expectations/matches.js +22 -0
- package/esm/expectations/matches.js.map +1 -0
- package/esm/expectations/not.d.ts +24 -0
- package/esm/expectations/not.d.ts.map +1 -0
- package/esm/expectations/not.js +48 -0
- package/esm/expectations/not.js.map +1 -0
- package/esm/expectations/or.d.ts +23 -0
- package/esm/expectations/or.d.ts.map +1 -0
- package/esm/expectations/or.js +53 -0
- package/esm/expectations/or.js.map +1 -0
- package/esm/expectations/property.d.ts +62 -0
- package/esm/expectations/property.d.ts.map +1 -0
- package/esm/expectations/property.js +82 -0
- package/esm/expectations/property.js.map +1 -0
- package/esm/expectations/startsWith.d.ts +22 -0
- package/esm/expectations/startsWith.d.ts.map +1 -0
- package/esm/expectations/startsWith.js +22 -0
- package/esm/expectations/startsWith.js.map +1 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +4 -0
- package/esm/index.js.map +1 -0
- package/lib/Ensure.d.ts +1 -1
- package/lib/Ensure.d.ts.map +1 -1
- package/lib/Ensure.js +2 -2
- package/lib/Ensure.js.map +1 -1
- package/lib/EnsureEventually.d.ts +1 -1
- package/lib/EnsureEventually.d.ts.map +1 -1
- package/lib/expectations/contain.js +2 -2
- package/lib/expectations/contain.js.map +1 -1
- package/lib/expectations/equals.js +2 -2
- package/lib/expectations/equals.js.map +1 -1
- package/lib/expectations/index.d.ts +20 -20
- package/lib/expectations/index.d.ts.map +1 -1
- package/lib/expectations/index.js +20 -20
- package/lib/expectations/index.js.map +1 -1
- package/lib/expectations/isAfter.d.ts +1 -1
- package/lib/expectations/isBefore.d.ts +1 -1
- package/lib/expectations/isFalse.js +2 -2
- package/lib/expectations/isFalse.js.map +1 -1
- package/lib/expectations/isTrue.js +2 -2
- package/lib/expectations/isTrue.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -0
- package/package.json +31 -8
- package/src/Ensure.ts +2 -2
- package/src/EnsureEventually.ts +1 -1
- package/src/expectations/contain.ts +1 -1
- package/src/expectations/equals.ts +1 -1
- package/src/expectations/index.ts +20 -20
- package/src/expectations/isFalse.ts +1 -1
- package/src/expectations/isTrue.ts +1 -1
- package/src/index.ts +3 -3
- package/tsconfig-cjs.build.json +17 -0
- package/tsconfig-esm.build.json +18 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Expectation } from '@serenity-js/core';
|
|
2
|
+
import { equal } from 'tiny-types/lib/objects/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Produces an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual array of `Item[]` contains
|
|
5
|
+
* at least one `Item` that is equal to the resolved value of `expected`.
|
|
6
|
+
*
|
|
7
|
+
* Note that the equality check performs comparison **by value**
|
|
8
|
+
* using [TinyTypes `equal`](https://github.com/jan-molak/tiny-types/blob/master/src/objects/equal.ts).
|
|
9
|
+
*
|
|
10
|
+
* ## Ensuring that the array contains the given item
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
14
|
+
* import { Ensure, and, startsWith, endsWith } from '@serenity-js/assertions'
|
|
15
|
+
*
|
|
16
|
+
* const items = [ { name: 'apples' }, { name: 'bananas' } ]
|
|
17
|
+
*
|
|
18
|
+
* await actorCalled('Ester').attemptsTo(
|
|
19
|
+
* Ensure.that(items, contain({ name: 'bananas' })),
|
|
20
|
+
* )
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param expected
|
|
24
|
+
*
|
|
25
|
+
* @group Expectations
|
|
26
|
+
*/
|
|
27
|
+
export const contain = Expectation.define('contain', 'contain', (actual, expected) => actual.some(item => equal(item, expected)));
|
|
28
|
+
//# sourceMappingURL=contain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contain.js","sourceRoot":"","sources":["../../src/expectations/contain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CACrC,SAAS,EAAE,SAAS,EACpB,CAAO,MAAc,EAAE,QAAc,EAAE,EAAE,CACrC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CACjD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Expectation } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Produces an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual array of `Item[]` contains
|
|
4
|
+
* at least one `Item` for which the `expectation` is met.
|
|
5
|
+
*
|
|
6
|
+
* ## Ensuring that at least one item in an array meets the expectation
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
10
|
+
* import { Ensure, containAtLeastOneItemThat, isGreaterThan } from '@serenity-js/assertions'
|
|
11
|
+
*
|
|
12
|
+
* const items = [ 10, 15, 20 ]
|
|
13
|
+
*
|
|
14
|
+
* await actorCalled('Ester').attemptsTo(
|
|
15
|
+
* Ensure.that(items, containAtLeastOneItemThat(isGreaterThan(18))),
|
|
16
|
+
* )
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param expectation
|
|
20
|
+
*
|
|
21
|
+
* @group Expectations
|
|
22
|
+
*/
|
|
23
|
+
export declare function containAtLeastOneItemThat<Item>(expectation: Expectation<Item>): Expectation<Item[]>;
|
|
24
|
+
//# sourceMappingURL=containAtLeastOneItemThat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containAtLeastOneItemThat.d.ts","sourceRoot":"","sources":["../../src/expectations/containAtLeastOneItemThat.ts"],"names":[],"mappings":"AACA,OAAO,EAAK,WAAW,EAAqE,MAAM,mBAAmB,CAAC;AAEtH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,CAEnG"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { d, Expectation, ExpectationDetails, ExpectationMet, ExpectationNotMet, Unanswered } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Produces an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual array of `Item[]` contains
|
|
4
|
+
* at least one `Item` for which the `expectation` is met.
|
|
5
|
+
*
|
|
6
|
+
* ## Ensuring that at least one item in an array meets the expectation
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
10
|
+
* import { Ensure, containAtLeastOneItemThat, isGreaterThan } from '@serenity-js/assertions'
|
|
11
|
+
*
|
|
12
|
+
* const items = [ 10, 15, 20 ]
|
|
13
|
+
*
|
|
14
|
+
* await actorCalled('Ester').attemptsTo(
|
|
15
|
+
* Ensure.that(items, containAtLeastOneItemThat(isGreaterThan(18))),
|
|
16
|
+
* )
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param expectation
|
|
20
|
+
*
|
|
21
|
+
* @group Expectations
|
|
22
|
+
*/
|
|
23
|
+
export function containAtLeastOneItemThat(expectation) {
|
|
24
|
+
return new ContainAtLeastOneItemThatMeetsExpectation(expectation);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @package
|
|
28
|
+
*/
|
|
29
|
+
class ContainAtLeastOneItemThatMeetsExpectation extends Expectation {
|
|
30
|
+
expectation;
|
|
31
|
+
static descriptionFor(expectation) {
|
|
32
|
+
return d `contain at least one item that does ${expectation}`;
|
|
33
|
+
}
|
|
34
|
+
constructor(expectation) {
|
|
35
|
+
super('containAtLeastOneItemThat', ContainAtLeastOneItemThatMeetsExpectation.descriptionFor(expectation), async (actor, actual) => {
|
|
36
|
+
const items = await actor.answer(actual);
|
|
37
|
+
if (!items || items.length === 0) {
|
|
38
|
+
const unanswered = new Unanswered();
|
|
39
|
+
return new ExpectationNotMet(ContainAtLeastOneItemThatMeetsExpectation.descriptionFor(expectation), ExpectationDetails.of('containAtLeastOneItemThat', unanswered), unanswered, items);
|
|
40
|
+
}
|
|
41
|
+
let outcome;
|
|
42
|
+
for (const item of items) {
|
|
43
|
+
outcome = await actor.answer(expectation.isMetFor(item));
|
|
44
|
+
if (outcome instanceof ExpectationMet) {
|
|
45
|
+
return new ExpectationMet(ContainAtLeastOneItemThatMeetsExpectation.descriptionFor(expectation), ExpectationDetails.of('containAtLeastOneItemThat', outcome.expectation), outcome.expected, items);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return new ExpectationNotMet(ContainAtLeastOneItemThatMeetsExpectation.descriptionFor(expectation), ExpectationDetails.of('containAtLeastOneItemThat', outcome.expectation), outcome.expected, items);
|
|
49
|
+
});
|
|
50
|
+
this.expectation = expectation;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=containAtLeastOneItemThat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containAtLeastOneItemThat.js","sourceRoot":"","sources":["../../src/expectations/containAtLeastOneItemThat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEtH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,yBAAyB,CAAO,WAA8B;IAC1E,OAAO,IAAI,yCAAyC,CAAC,WAAW,CAAC,CAAC;AACtE,CAAC;AAED;;GAEG;AACH,MAAM,yCAAgD,SAAQ,WAAmB;IAMhD;IAJrB,MAAM,CAAC,cAAc,CAAC,WAA6B;QACvD,OAAO,CAAC,CAAA,uCAAwC,WAAY,EAAE,CAAC;IACnE,CAAC;IAED,YAA6B,WAA8B;QACvD,KAAK,CACD,2BAA2B,EAC3B,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,KAAK,EAAE,KAAuB,EAAE,MAA0B,EAAE,EAAE;YAE1D,MAAM,KAAK,GAAW,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAEjD,IAAI,CAAE,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAChC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;gBACpC,OAAO,IAAI,iBAAiB,CACxB,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,kBAAkB,CAAC,EAAE,CAAC,2BAA2B,EAAE,UAAU,CAAC,EAC9D,UAAU,EACV,KAAK,CACR,CAAC;YACN,CAAC;YAED,IAAI,OAA2B,CAAC;YAEhC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBAEvB,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;gBAExD,IAAI,OAAO,YAAY,cAAc,EAAE,CAAC;oBACpC,OAAO,IAAI,cAAc,CACrB,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,kBAAkB,CAAC,EAAE,CAAC,2BAA2B,EAAE,OAAO,CAAC,WAAW,CAAC,EACvE,OAAO,CAAC,QAAQ,EAChB,KAAK,CACR,CAAC;gBACN,CAAC;YACL,CAAC;YAED,OAAO,IAAI,iBAAiB,CACxB,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,kBAAkB,CAAC,EAAE,CAAC,2BAA2B,EAAE,OAAO,CAAC,WAAW,CAAC,EACvE,OAAO,CAAC,QAAQ,EAChB,KAAK,CACR,CAAC;QACN,CAAC,CACJ,CAAC;QAzCuB,gBAAW,GAAX,WAAW,CAAmB;IA0C3D,CAAC;CACJ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Expectation } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Produces an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when all the items of the actual array of `Item[]`
|
|
4
|
+
* meet the `expectation`.
|
|
5
|
+
*
|
|
6
|
+
* ## Ensuring that all the items in an array meet the expectation
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
10
|
+
* import { Ensure, containItemsWhereEachItem, endsWith } from '@serenity-js/assertions'
|
|
11
|
+
*
|
|
12
|
+
* const items = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday' ]
|
|
13
|
+
*
|
|
14
|
+
* await actorCalled('Ester').attemptsTo(
|
|
15
|
+
* Ensure.that(items, containItemsWhereEachItem(endsWith('day'))),
|
|
16
|
+
* )
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param expectation
|
|
20
|
+
*
|
|
21
|
+
* @group Expectations
|
|
22
|
+
*/
|
|
23
|
+
export declare function containItemsWhereEachItem<Actual>(expectation: Expectation<Actual>): Expectation<Actual[]>;
|
|
24
|
+
//# sourceMappingURL=containItemsWhereEachItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containItemsWhereEachItem.d.ts","sourceRoot":"","sources":["../../src/expectations/containItemsWhereEachItem.ts"],"names":[],"mappings":"AACA,OAAO,EAAK,WAAW,EAAqE,MAAM,mBAAmB,CAAC;AAEtH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAEzG"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { d, Expectation, ExpectationDetails, ExpectationMet, ExpectationNotMet, Unanswered } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Produces an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when all the items of the actual array of `Item[]`
|
|
4
|
+
* meet the `expectation`.
|
|
5
|
+
*
|
|
6
|
+
* ## Ensuring that all the items in an array meet the expectation
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
10
|
+
* import { Ensure, containItemsWhereEachItem, endsWith } from '@serenity-js/assertions'
|
|
11
|
+
*
|
|
12
|
+
* const items = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday' ]
|
|
13
|
+
*
|
|
14
|
+
* await actorCalled('Ester').attemptsTo(
|
|
15
|
+
* Ensure.that(items, containItemsWhereEachItem(endsWith('day'))),
|
|
16
|
+
* )
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param expectation
|
|
20
|
+
*
|
|
21
|
+
* @group Expectations
|
|
22
|
+
*/
|
|
23
|
+
export function containItemsWhereEachItem(expectation) {
|
|
24
|
+
return new ContainItemsWhereEachItemMeetsExpectation(expectation);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @package
|
|
28
|
+
*/
|
|
29
|
+
class ContainItemsWhereEachItemMeetsExpectation extends Expectation {
|
|
30
|
+
expectation;
|
|
31
|
+
static descriptionFor(expectation) {
|
|
32
|
+
return d `contain items where each item does ${expectation}`;
|
|
33
|
+
}
|
|
34
|
+
constructor(expectation) {
|
|
35
|
+
super('containItemsWhereEachItem', ContainItemsWhereEachItemMeetsExpectation.descriptionFor(expectation), async (actor, actual) => {
|
|
36
|
+
const items = await actor.answer(actual);
|
|
37
|
+
if (!items || items.length === 0) {
|
|
38
|
+
const unanswered = new Unanswered();
|
|
39
|
+
return new ExpectationNotMet(ContainItemsWhereEachItemMeetsExpectation.descriptionFor(expectation), ExpectationDetails.of('containItemsWhereEachItem', unanswered), unanswered, items);
|
|
40
|
+
}
|
|
41
|
+
let outcome;
|
|
42
|
+
for (const item of items) {
|
|
43
|
+
outcome = await actor.answer(expectation.isMetFor(item));
|
|
44
|
+
if (outcome instanceof ExpectationNotMet) {
|
|
45
|
+
return new ExpectationNotMet(ContainItemsWhereEachItemMeetsExpectation.descriptionFor(expectation), ExpectationDetails.of('containItemsWhereEachItem', outcome.expectation), outcome.expected, items);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return new ExpectationMet(ContainItemsWhereEachItemMeetsExpectation.descriptionFor(expectation), ExpectationDetails.of('containItemsWhereEachItem', outcome.expectation), outcome.expected, items);
|
|
49
|
+
});
|
|
50
|
+
this.expectation = expectation;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=containItemsWhereEachItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containItemsWhereEachItem.js","sourceRoot":"","sources":["../../src/expectations/containItemsWhereEachItem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEtH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,yBAAyB,CAAS,WAAgC;IAC9E,OAAO,IAAI,yCAAyC,CAAC,WAAW,CAAC,CAAC;AACtE,CAAC;AAED;;GAEG;AACH,MAAM,yCAAkD,SAAQ,WAAqB;IAMpD;IAJrB,MAAM,CAAC,cAAc,CAAC,WAA6B;QACvD,OAAO,CAAC,CAAA,sCAAuC,WAAY,EAAE,CAAC;IAClE,CAAC;IAED,YAA6B,WAAgC;QACzD,KAAK,CACD,2BAA2B,EAC3B,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,CAAC;gBAChC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;gBACpC,OAAO,IAAI,iBAAiB,CACxB,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,kBAAkB,CAAC,EAAE,CAAC,2BAA2B,EAAE,UAAU,CAAC,EAC9D,UAAU,EACV,KAAK,CACR,CAAC;YACN,CAAC;YAED,IAAI,OAA2B,CAAC;YAEhC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBAEvB,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;gBAExD,IAAI,OAAO,YAAY,iBAAiB,EAAE,CAAC;oBACvC,OAAO,IAAI,iBAAiB,CACxB,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,kBAAkB,CAAC,EAAE,CAAC,2BAA2B,EAAE,OAAO,CAAC,WAAW,CAAC,EACvE,OAAO,CAAC,QAAQ,EAChB,KAAK,CACR,CAAC;gBACN,CAAC;YACL,CAAC;YAED,OAAO,IAAI,cAAc,CACrB,yCAAyC,CAAC,cAAc,CAAC,WAAW,CAAC,EACrE,kBAAkB,CAAC,EAAE,CAAC,2BAA2B,EAAE,OAAO,CAAC,WAAW,CAAC,EACvE,OAAO,CAAC,QAAQ,EAChB,KAAK,CACR,CAAC;QACN,CAAC,CACJ,CAAC;QAzCuB,gBAAW,GAAX,WAAW,CAAqB;IA0C7D,CAAC;CACJ"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Expectation } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual `string` value
|
|
4
|
+
* ends with the resolved value of `expected`.
|
|
5
|
+
*
|
|
6
|
+
* ## Ensuring that a given string ends with an expected substring
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
10
|
+
* import { Ensure, endsWith } from '@serenity-js/assertions'
|
|
11
|
+
*
|
|
12
|
+
* await actorCalled('Ester').attemptsTo(
|
|
13
|
+
* Ensure.that('Hello World!', endsWith('!')),
|
|
14
|
+
* )
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param expected
|
|
18
|
+
*
|
|
19
|
+
* @group Expectations
|
|
20
|
+
*/
|
|
21
|
+
export declare const endsWith: (expected: import("@serenity-js/core").Answerable<string>) => Expectation<string>;
|
|
22
|
+
//# sourceMappingURL=endsWith.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endsWith.d.ts","sourceRoot":"","sources":["../../src/expectations/endsWith.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,QAAQ,mFAIpB,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Expectation } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual `string` value
|
|
4
|
+
* ends with the resolved value of `expected`.
|
|
5
|
+
*
|
|
6
|
+
* ## Ensuring that a given string ends with an expected substring
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
10
|
+
* import { Ensure, endsWith } from '@serenity-js/assertions'
|
|
11
|
+
*
|
|
12
|
+
* await actorCalled('Ester').attemptsTo(
|
|
13
|
+
* Ensure.that('Hello World!', endsWith('!')),
|
|
14
|
+
* )
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param expected
|
|
18
|
+
*
|
|
19
|
+
* @group Expectations
|
|
20
|
+
*/
|
|
21
|
+
export const endsWith = Expectation.define('endsWith', 'end with', (actual, expected) => actual.endsWith(expected));
|
|
22
|
+
//# sourceMappingURL=endsWith.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endsWith.js","sourceRoot":"","sources":["../../src/expectations/endsWith.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CACtC,UAAU,EAAE,UAAU,EACtB,CAAC,MAAc,EAAE,QAAgB,EAAE,EAAE,CACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAChC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Expectation } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Produces an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual value
|
|
4
|
+
* is equal to the resolved value of `expectedValue`.
|
|
5
|
+
*
|
|
6
|
+
* Note that the equality check performs comparison **by value**
|
|
7
|
+
* using [TinyTypes `equal`](https://github.com/jan-molak/tiny-types/blob/master/src/objects/equal.ts).
|
|
8
|
+
*
|
|
9
|
+
* ## Ensuring that the actual value equals expected value
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
13
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
14
|
+
*
|
|
15
|
+
* const actual = { name: 'apples' }
|
|
16
|
+
* const expected = { name: 'apples' }
|
|
17
|
+
*
|
|
18
|
+
* await actorCalled('Ester').attemptsTo(
|
|
19
|
+
* Ensure.that(actual, equals(expected)),
|
|
20
|
+
* )
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param expectedValue
|
|
24
|
+
*
|
|
25
|
+
* @group Expectations
|
|
26
|
+
*/
|
|
27
|
+
export declare const equals: <T>(expected: import("@serenity-js/core").Answerable<T>) => Expectation<T>;
|
|
28
|
+
//# sourceMappingURL=equals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../src/expectations/equals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,MAAM,GAEd,CAAC,wEAEL,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Expectation } from '@serenity-js/core';
|
|
2
|
+
import { equal } from 'tiny-types/lib/objects/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Produces an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual value
|
|
5
|
+
* is equal to the resolved value of `expectedValue`.
|
|
6
|
+
*
|
|
7
|
+
* Note that the equality check performs comparison **by value**
|
|
8
|
+
* using [TinyTypes `equal`](https://github.com/jan-molak/tiny-types/blob/master/src/objects/equal.ts).
|
|
9
|
+
*
|
|
10
|
+
* ## Ensuring that the actual value equals expected value
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
14
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
15
|
+
*
|
|
16
|
+
* const actual = { name: 'apples' }
|
|
17
|
+
* const expected = { name: 'apples' }
|
|
18
|
+
*
|
|
19
|
+
* await actorCalled('Ester').attemptsTo(
|
|
20
|
+
* Ensure.that(actual, equals(expected)),
|
|
21
|
+
* )
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param expectedValue
|
|
25
|
+
*
|
|
26
|
+
* @group Expectations
|
|
27
|
+
*/
|
|
28
|
+
export const equals = Expectation.define('equals', 'equal', (actual, expected) => equal(actual, expected));
|
|
29
|
+
//# sourceMappingURL=equals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"equals.js","sourceRoot":"","sources":["../../src/expectations/equals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CACpC,QAAQ,EAAE,OAAO,EACjB,CAAI,MAAS,EAAE,QAAW,EAAE,EAAE,CAC1B,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAC9B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Expectation } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual `string` value
|
|
4
|
+
* includes a substring of `expected`.
|
|
5
|
+
*
|
|
6
|
+
* ## Ensuring that a given string includes the expected substring
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
10
|
+
* import { Ensure, includes } from '@serenity-js/assertions'
|
|
11
|
+
*
|
|
12
|
+
* await actorCalled('Ester').attemptsTo(
|
|
13
|
+
* Ensure.that('Hello World!', includes('World')),
|
|
14
|
+
* )
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ## Ensuring that page URL includes the expected substring
|
|
18
|
+
*
|
|
19
|
+
* [`Page.current().url()`](https://serenity-js.org/api/web/class/Page/#url) returns a [`QuestionAdapter<URL>`](https://serenity-js.org/api/core/#QuestionAdapter)
|
|
20
|
+
* a proxy object around the standard Node.js [URL](https://nodejs.org/api/url.html) class,
|
|
21
|
+
* offering access to `string` properties such as [`hostname`](https://nodejs.org/api/url.html#urlobjecthostname),
|
|
22
|
+
* [`pathname`](https://nodejs.org/api/url.html#urlobjectpathname), and so on.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
26
|
+
* import { Ensure, includes } from '@serenity-js/assertions'
|
|
27
|
+
* import { Navigate, Page } from '@serenity-js/web'
|
|
28
|
+
*
|
|
29
|
+
* await actorCalled('Ester').attemptsTo(
|
|
30
|
+
* Navigate.to('https://serenity-js.org/handbook'),
|
|
31
|
+
* Ensure.that(Page.current().url().hostname, includes('serenity-js')),
|
|
32
|
+
* Ensure.that(Page.current().url().pathname, includes('book')),
|
|
33
|
+
* )
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param expected
|
|
37
|
+
*
|
|
38
|
+
* @group Expectations
|
|
39
|
+
*/
|
|
40
|
+
export declare const includes: (expected: import("@serenity-js/core").Answerable<string>) => Expectation<string>;
|
|
41
|
+
//# sourceMappingURL=includes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"includes.d.ts","sourceRoot":"","sources":["../../src/expectations/includes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,QAAQ,mFAIpB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Expectation } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual `string` value
|
|
4
|
+
* includes a substring of `expected`.
|
|
5
|
+
*
|
|
6
|
+
* ## Ensuring that a given string includes the expected substring
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
10
|
+
* import { Ensure, includes } from '@serenity-js/assertions'
|
|
11
|
+
*
|
|
12
|
+
* await actorCalled('Ester').attemptsTo(
|
|
13
|
+
* Ensure.that('Hello World!', includes('World')),
|
|
14
|
+
* )
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ## Ensuring that page URL includes the expected substring
|
|
18
|
+
*
|
|
19
|
+
* [`Page.current().url()`](https://serenity-js.org/api/web/class/Page/#url) returns a [`QuestionAdapter<URL>`](https://serenity-js.org/api/core/#QuestionAdapter)
|
|
20
|
+
* a proxy object around the standard Node.js [URL](https://nodejs.org/api/url.html) class,
|
|
21
|
+
* offering access to `string` properties such as [`hostname`](https://nodejs.org/api/url.html#urlobjecthostname),
|
|
22
|
+
* [`pathname`](https://nodejs.org/api/url.html#urlobjectpathname), and so on.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
26
|
+
* import { Ensure, includes } from '@serenity-js/assertions'
|
|
27
|
+
* import { Navigate, Page } from '@serenity-js/web'
|
|
28
|
+
*
|
|
29
|
+
* await actorCalled('Ester').attemptsTo(
|
|
30
|
+
* Navigate.to('https://serenity-js.org/handbook'),
|
|
31
|
+
* Ensure.that(Page.current().url().hostname, includes('serenity-js')),
|
|
32
|
+
* Ensure.that(Page.current().url().pathname, includes('book')),
|
|
33
|
+
* )
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param expected
|
|
37
|
+
*
|
|
38
|
+
* @group Expectations
|
|
39
|
+
*/
|
|
40
|
+
export const includes = Expectation.define('includes', 'include', (actual, expected) => actual.includes(expected));
|
|
41
|
+
//# sourceMappingURL=includes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"includes.js","sourceRoot":"","sources":["../../src/expectations/includes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CACtC,UAAU,EAAE,SAAS,EACrB,CAAC,MAAc,EAAE,QAAgB,EAAE,EAAE,CACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAChC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from './and.js';
|
|
2
|
+
export * from './contain.js';
|
|
3
|
+
export * from './containAtLeastOneItemThat.js';
|
|
4
|
+
export * from './containItemsWhereEachItem.js';
|
|
5
|
+
export * from './endsWith.js';
|
|
6
|
+
export * from './equals.js';
|
|
7
|
+
export * from './includes.js';
|
|
8
|
+
export * from './isAfter.js';
|
|
9
|
+
export * from './isBefore.js';
|
|
10
|
+
export * from './isCloseTo.js';
|
|
11
|
+
export * from './isFalse.js';
|
|
12
|
+
export * from './isGreaterThan.js';
|
|
13
|
+
export * from './isLessThan.js';
|
|
14
|
+
export * from './isPresent.js';
|
|
15
|
+
export * from './isTrue.js';
|
|
16
|
+
export * from './matches.js';
|
|
17
|
+
export * from './not.js';
|
|
18
|
+
export * from './or.js';
|
|
19
|
+
export * from './property.js';
|
|
20
|
+
export * from './startsWith.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expectations/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from './and.js';
|
|
2
|
+
export * from './contain.js';
|
|
3
|
+
export * from './containAtLeastOneItemThat.js';
|
|
4
|
+
export * from './containItemsWhereEachItem.js';
|
|
5
|
+
export * from './endsWith.js';
|
|
6
|
+
export * from './equals.js';
|
|
7
|
+
export * from './includes.js';
|
|
8
|
+
export * from './isAfter.js';
|
|
9
|
+
export * from './isBefore.js';
|
|
10
|
+
export * from './isCloseTo.js';
|
|
11
|
+
export * from './isFalse.js';
|
|
12
|
+
export * from './isGreaterThan.js';
|
|
13
|
+
export * from './isLessThan.js';
|
|
14
|
+
export * from './isPresent.js';
|
|
15
|
+
export * from './isTrue.js';
|
|
16
|
+
export * from './matches.js';
|
|
17
|
+
export * from './not.js';
|
|
18
|
+
export * from './or.js';
|
|
19
|
+
export * from './property.js';
|
|
20
|
+
export * from './startsWith.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/expectations/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Expectation, type Timestamp } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual value of type `Date`
|
|
4
|
+
* is after the expected `Date`.
|
|
5
|
+
*
|
|
6
|
+
* ## Ensuring that a given date is after the expected date
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
10
|
+
* import { Ensure, isAfter } from '@serenity-js/assertions'
|
|
11
|
+
*
|
|
12
|
+
* await actorCalled('Ester').attemptsTo(
|
|
13
|
+
* Ensure.that(new Date('2022-01-01'), isAfter(new Date('1995-01-01'))),
|
|
14
|
+
* )
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ## Ensuring that a given date is within the expected date range
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { actorCalled, Expectation, d } from '@serenity-js/core'
|
|
21
|
+
* import { Ensure, and, isAfter, isBefore } from '@serenity-js/assertions'
|
|
22
|
+
*
|
|
23
|
+
* const isWithinDateRange = (lowerBound: Answerable<Date>, upperBound: Answerable<Date>) =>
|
|
24
|
+
* Expectation.to(d`have value that is between ${ lowerBound } and ${ upperBound }`)
|
|
25
|
+
* .soThatActual(
|
|
26
|
+
* and(isAfter(lowerBound), isBefore(upperBound))
|
|
27
|
+
* ),
|
|
28
|
+
*
|
|
29
|
+
* await actorCalled('Ester').attemptsTo(
|
|
30
|
+
* Ensure.that(
|
|
31
|
+
* new Date('2022-01-01'),
|
|
32
|
+
* isWithinDateRange(new Date('1995-01-01'), new Date('2025-01-01'))
|
|
33
|
+
* ),
|
|
34
|
+
* )
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param expected
|
|
38
|
+
*
|
|
39
|
+
* @group Expectations
|
|
40
|
+
*/
|
|
41
|
+
export declare const isAfter: (expected: import("@serenity-js/core").Answerable<Timestamp | Date>) => Expectation<Timestamp | Date>;
|
|
42
|
+
//# sourceMappingURL=isAfter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isAfter.d.ts","sourceRoot":"","sources":["../../src/expectations/isAfter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,OAAO,uGAanB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Expectation } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual value of type `Date`
|
|
4
|
+
* is after the expected `Date`.
|
|
5
|
+
*
|
|
6
|
+
* ## Ensuring that a given date is after the expected date
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
10
|
+
* import { Ensure, isAfter } from '@serenity-js/assertions'
|
|
11
|
+
*
|
|
12
|
+
* await actorCalled('Ester').attemptsTo(
|
|
13
|
+
* Ensure.that(new Date('2022-01-01'), isAfter(new Date('1995-01-01'))),
|
|
14
|
+
* )
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ## Ensuring that a given date is within the expected date range
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { actorCalled, Expectation, d } from '@serenity-js/core'
|
|
21
|
+
* import { Ensure, and, isAfter, isBefore } from '@serenity-js/assertions'
|
|
22
|
+
*
|
|
23
|
+
* const isWithinDateRange = (lowerBound: Answerable<Date>, upperBound: Answerable<Date>) =>
|
|
24
|
+
* Expectation.to(d`have value that is between ${ lowerBound } and ${ upperBound }`)
|
|
25
|
+
* .soThatActual(
|
|
26
|
+
* and(isAfter(lowerBound), isBefore(upperBound))
|
|
27
|
+
* ),
|
|
28
|
+
*
|
|
29
|
+
* await actorCalled('Ester').attemptsTo(
|
|
30
|
+
* Ensure.that(
|
|
31
|
+
* new Date('2022-01-01'),
|
|
32
|
+
* isWithinDateRange(new Date('1995-01-01'), new Date('2025-01-01'))
|
|
33
|
+
* ),
|
|
34
|
+
* )
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param expected
|
|
38
|
+
*
|
|
39
|
+
* @group Expectations
|
|
40
|
+
*/
|
|
41
|
+
export const isAfter = Expectation.define('isAfter', 'have value that is after', (actual, expected) => {
|
|
42
|
+
const actualInMilliseconds = actual instanceof Date
|
|
43
|
+
? actual.getTime()
|
|
44
|
+
: actual.toMilliseconds();
|
|
45
|
+
const expectedInMilliseconds = expected instanceof Date
|
|
46
|
+
? expected.getTime()
|
|
47
|
+
: expected.toMilliseconds();
|
|
48
|
+
return actualInMilliseconds > expectedInMilliseconds;
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=isAfter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isAfter.js","sourceRoot":"","sources":["../../src/expectations/isAfter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CACrC,SAAS,EAAE,0BAA0B,EACrC,CAAC,MAAwB,EAAE,QAA0B,EAAE,EAAE;IACrD,MAAM,oBAAoB,GAAG,MAAM,YAAY,IAAI;QAC/C,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE;QAClB,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;IAE9B,MAAM,sBAAsB,GAAG,QAAQ,YAAY,IAAI;QACnD,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE;QACpB,CAAC,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;IAEhC,OAAO,oBAAoB,GAAG,sBAAsB,CAAC;AACzD,CAAC,CACJ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Expectation, type Timestamp } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual value of type `Date`
|
|
4
|
+
* is before the expected `Date`.
|
|
5
|
+
*
|
|
6
|
+
* ## Ensuring that a given date is after the expected date
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
10
|
+
* import { Ensure, isBefore } from '@serenity-js/assertions'
|
|
11
|
+
*
|
|
12
|
+
* await actorCalled('Ester').attemptsTo(
|
|
13
|
+
* Ensure.that(new Date('1995-01-01'), isBefore(new Date('2022-01-01'))),
|
|
14
|
+
* )
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ## Ensuring that a given date is within the expected date range
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { actorCalled, Expectation, d } from '@serenity-js/core'
|
|
21
|
+
* import { Ensure, and, isAfter, isBefore } from '@serenity-js/assertions'
|
|
22
|
+
*
|
|
23
|
+
* const isWithinDateRange = (lowerBound: Answerable<Date>, upperBound: Answerable<Date>) =>
|
|
24
|
+
* Expectation.to(d`have value that is between ${ lowerBound } and ${ upperBound }`)
|
|
25
|
+
* .soThatActual(
|
|
26
|
+
* and(isAfter(lowerBound), isBefore(upperBound))
|
|
27
|
+
* ),
|
|
28
|
+
*
|
|
29
|
+
* await actorCalled('Ester').attemptsTo(
|
|
30
|
+
* Ensure.that(
|
|
31
|
+
* new Date('2022-01-01'),
|
|
32
|
+
* isWithinDateRange(new Date('1995-01-01'), new Date('2025-01-01'))
|
|
33
|
+
* ),
|
|
34
|
+
* )
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param expected
|
|
38
|
+
*
|
|
39
|
+
* @group Expectations
|
|
40
|
+
*/
|
|
41
|
+
export declare const isBefore: (expected: import("@serenity-js/core").Answerable<Timestamp | Date>) => Expectation<Timestamp | Date>;
|
|
42
|
+
//# sourceMappingURL=isBefore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isBefore.d.ts","sourceRoot":"","sources":["../../src/expectations/isBefore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,QAAQ,uGAcpB,CAAC"}
|