@serenity-js/core 2.33.1 → 3.0.0-rc.11
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 +476 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -1
- package/lib/index.js.map +1 -1
- package/lib/io/ErrorSerialiser.js +4 -1
- package/lib/io/ErrorSerialiser.js.map +1 -1
- package/lib/io/ErrorStackParser.d.ts +2 -2
- package/lib/io/ErrorStackParser.js.map +1 -1
- package/lib/io/asyncMap.d.ts +8 -0
- package/lib/io/asyncMap.js +18 -0
- package/lib/io/asyncMap.js.map +1 -0
- package/lib/io/format.d.ts +39 -0
- package/lib/io/format.js +51 -0
- package/lib/io/format.js.map +1 -0
- package/lib/io/formatted.d.ts +5 -1
- package/lib/io/formatted.js +6 -13
- package/lib/io/formatted.js.map +1 -1
- package/lib/io/index.d.ts +2 -1
- package/lib/io/index.js +2 -1
- package/lib/io/index.js.map +1 -1
- package/lib/io/inspected.d.ts +9 -1
- package/lib/io/inspected.js +52 -15
- package/lib/io/inspected.js.map +1 -1
- package/lib/model/Timestamp.d.ts +4 -2
- package/lib/model/Timestamp.js +8 -2
- package/lib/model/Timestamp.js.map +1 -1
- package/lib/screenplay/Optional.d.ts +29 -0
- package/lib/{io/collections/reducible.js → screenplay/Optional.js} +1 -1
- package/lib/screenplay/Optional.js.map +1 -0
- package/lib/screenplay/Question.d.ts +41 -82
- package/lib/screenplay/Question.js +132 -100
- package/lib/screenplay/Question.js.map +1 -1
- package/lib/screenplay/actor/Actor.js +2 -2
- package/lib/screenplay/actor/Actor.js.map +1 -1
- package/lib/screenplay/index.d.ts +1 -1
- package/lib/screenplay/index.js +1 -1
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/interactions/index.d.ts +0 -1
- package/lib/screenplay/interactions/index.js +0 -1
- package/lib/screenplay/interactions/index.js.map +1 -1
- package/lib/screenplay/questions/Check.d.ts +3 -3
- package/lib/screenplay/questions/Check.js +5 -7
- package/lib/screenplay/questions/Check.js.map +1 -1
- package/lib/screenplay/questions/Expectation.d.ts +15 -10
- package/lib/screenplay/questions/Expectation.js +28 -37
- package/lib/screenplay/questions/Expectation.js.map +1 -1
- package/lib/screenplay/questions/List.d.ts +22 -192
- package/lib/screenplay/questions/List.js +160 -208
- package/lib/screenplay/questions/List.js.map +1 -1
- package/lib/screenplay/questions/Note.d.ts +10 -0
- package/lib/screenplay/questions/Note.js +17 -1
- package/lib/screenplay/questions/Note.js.map +1 -1
- package/lib/screenplay/questions/index.d.ts +0 -3
- package/lib/screenplay/questions/index.js +0 -5
- package/lib/screenplay/questions/index.js.map +1 -1
- package/lib/stage/index.d.ts +0 -2
- package/lib/stage/index.js +0 -2
- package/lib/stage/index.js.map +1 -1
- package/package.json +7 -6
- package/src/index.ts +2 -1
- package/src/io/ErrorSerialiser.ts +5 -1
- package/src/io/ErrorStackParser.ts +2 -1
- package/src/io/asyncMap.ts +18 -0
- package/src/io/format.ts +49 -0
- package/src/io/formatted.ts +7 -15
- package/src/io/index.ts +2 -1
- package/src/io/inspected.ts +68 -15
- package/src/model/Timestamp.ts +10 -2
- package/src/screenplay/Optional.ts +30 -0
- package/src/screenplay/Question.ts +206 -124
- package/src/screenplay/actor/Actor.ts +2 -2
- package/src/screenplay/index.ts +1 -1
- package/src/screenplay/interactions/index.ts +0 -1
- package/src/screenplay/questions/Check.ts +10 -15
- package/src/screenplay/questions/Expectation.ts +47 -55
- package/src/screenplay/questions/List.ts +224 -233
- package/src/screenplay/questions/Note.ts +21 -1
- package/src/screenplay/questions/index.ts +0 -3
- package/src/stage/index.ts +0 -2
- package/lib/io/collections/index.d.ts +0 -2
- package/lib/io/collections/index.js +0 -15
- package/lib/io/collections/index.js.map +0 -1
- package/lib/io/collections/mappable.d.ts +0 -52
- package/lib/io/collections/mappable.js +0 -28
- package/lib/io/collections/mappable.js.map +0 -1
- package/lib/io/collections/reducible.d.ts +0 -16
- package/lib/io/collections/reducible.js.map +0 -1
- package/lib/screenplay/interactions/See.d.ts +0 -31
- package/lib/screenplay/interactions/See.js +0 -43
- package/lib/screenplay/interactions/See.js.map +0 -1
- package/lib/screenplay/questions/Property.d.ts +0 -91
- package/lib/screenplay/questions/Property.js +0 -99
- package/lib/screenplay/questions/Property.js.map +0 -1
- package/lib/screenplay/questions/Transform.d.ts +0 -31
- package/lib/screenplay/questions/Transform.js +0 -46
- package/lib/screenplay/questions/Transform.js.map +0 -1
- package/lib/screenplay/questions/lists/ArrayListAdapter.d.ts +0 -88
- package/lib/screenplay/questions/lists/ArrayListAdapter.js +0 -152
- package/lib/screenplay/questions/lists/ArrayListAdapter.js.map +0 -1
- package/lib/screenplay/questions/lists/ListAdapter.d.ts +0 -20
- package/lib/screenplay/questions/lists/ListAdapter.js +0 -3
- package/lib/screenplay/questions/lists/ListAdapter.js.map +0 -1
- package/lib/screenplay/questions/lists/index.d.ts +0 -2
- package/lib/screenplay/questions/lists/index.js +0 -15
- package/lib/screenplay/questions/lists/index.js.map +0 -1
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.d.ts +0 -11
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.js +0 -3
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.js.map +0 -1
- package/lib/screenplay/questions/mappings/index.d.ts +0 -2
- package/lib/screenplay/questions/mappings/index.js +0 -15
- package/lib/screenplay/questions/mappings/index.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/append.d.ts +0 -14
- package/lib/screenplay/questions/mappings/string/append.js +0 -25
- package/lib/screenplay/questions/mappings/string/append.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/index.d.ts +0 -11
- package/lib/screenplay/questions/mappings/string/index.js +0 -24
- package/lib/screenplay/questions/mappings/string/index.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/normalize.d.ts +0 -20
- package/lib/screenplay/questions/mappings/string/normalize.js +0 -30
- package/lib/screenplay/questions/mappings/string/normalize.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/replace.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/replace.js +0 -30
- package/lib/screenplay/questions/mappings/string/replace.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/slice.d.ts +0 -28
- package/lib/screenplay/questions/mappings/string/slice.js +0 -47
- package/lib/screenplay/questions/mappings/string/slice.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/split.d.ts +0 -19
- package/lib/screenplay/questions/mappings/string/split.js +0 -36
- package/lib/screenplay/questions/mappings/string/split.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js +0 -28
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js +0 -29
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLowerCase.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toLowerCase.js +0 -19
- package/lib/screenplay/questions/mappings/string/toLowerCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toNumber.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toNumber.js +0 -18
- package/lib/screenplay/questions/mappings/string/toNumber.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toUpperCase.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toUpperCase.js +0 -19
- package/lib/screenplay/questions/mappings/string/toUpperCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/trim.d.ts +0 -12
- package/lib/screenplay/questions/mappings/string/trim.js +0 -21
- package/lib/screenplay/questions/mappings/string/trim.js.map +0 -1
- package/lib/screenplay/questions/proxies/PropertyPathKey.d.ts +0 -4
- package/lib/screenplay/questions/proxies/PropertyPathKey.js +0 -3
- package/lib/screenplay/questions/proxies/PropertyPathKey.js.map +0 -1
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.d.ts +0 -14
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js +0 -35
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js.map +0 -1
- package/lib/screenplay/questions/proxies/createQuestionProxy.d.ts +0 -13
- package/lib/screenplay/questions/proxies/createQuestionProxy.js +0 -34
- package/lib/screenplay/questions/proxies/createQuestionProxy.js.map +0 -1
- package/lib/screenplay/questions/proxies/describePath.d.ts +0 -5
- package/lib/screenplay/questions/proxies/describePath.js +0 -19
- package/lib/screenplay/questions/proxies/describePath.js.map +0 -1
- package/lib/screenplay/questions/proxies/index.d.ts +0 -2
- package/lib/screenplay/questions/proxies/index.js +0 -15
- package/lib/screenplay/questions/proxies/index.js.map +0 -1
- package/lib/screenplay/questions/proxies/key.d.ts +0 -8
- package/lib/screenplay/questions/proxies/key.js +0 -16
- package/lib/screenplay/questions/proxies/key.js.map +0 -1
- package/lib/screenplay/tasks/Loop.d.ts +0 -198
- package/lib/screenplay/tasks/Loop.js +0 -222
- package/lib/screenplay/tasks/Loop.js.map +0 -1
- package/lib/screenplay/tasks/index.d.ts +0 -1
- package/lib/screenplay/tasks/index.js +0 -14
- package/lib/screenplay/tasks/index.js.map +0 -1
- package/lib/stage/DressingRoom.d.ts +0 -37
- package/lib/stage/DressingRoom.js +0 -53
- package/lib/stage/DressingRoom.js.map +0 -1
- package/lib/stage/WithStage.d.ts +0 -51
- package/lib/stage/WithStage.js +0 -3
- package/lib/stage/WithStage.js.map +0 -1
- package/src/io/collections/index.ts +0 -2
- package/src/io/collections/mappable.ts +0 -60
- package/src/io/collections/reducible.ts +0 -16
- package/src/screenplay/interactions/See.ts +0 -45
- package/src/screenplay/questions/Property.ts +0 -98
- package/src/screenplay/questions/Transform.ts +0 -51
- package/src/screenplay/questions/lists/ArrayListAdapter.ts +0 -186
- package/src/screenplay/questions/lists/ListAdapter.ts +0 -33
- package/src/screenplay/questions/lists/index.ts +0 -2
- package/src/screenplay/questions/mappings/AnswerMappingFunction.ts +0 -13
- package/src/screenplay/questions/mappings/index.ts +0 -2
- package/src/screenplay/questions/mappings/string/append.ts +0 -28
- package/src/screenplay/questions/mappings/string/index.ts +0 -11
- package/src/screenplay/questions/mappings/string/normalize.ts +0 -33
- package/src/screenplay/questions/mappings/string/replace.ts +0 -34
- package/src/screenplay/questions/mappings/string/slice.ts +0 -53
- package/src/screenplay/questions/mappings/string/split.ts +0 -38
- package/src/screenplay/questions/mappings/string/toLocaleLowerCase.ts +0 -31
- package/src/screenplay/questions/mappings/string/toLocaleUpperCase.ts +0 -30
- package/src/screenplay/questions/mappings/string/toLowerCase.ts +0 -20
- package/src/screenplay/questions/mappings/string/toNumber.ts +0 -19
- package/src/screenplay/questions/mappings/string/toUpperCase.ts +0 -20
- package/src/screenplay/questions/mappings/string/trim.ts +0 -22
- package/src/screenplay/questions/proxies/PropertyPathKey.ts +0 -4
- package/src/screenplay/questions/proxies/createMetaQuestionProxy.ts +0 -51
- package/src/screenplay/questions/proxies/createQuestionProxy.ts +0 -49
- package/src/screenplay/questions/proxies/describePath.ts +0 -23
- package/src/screenplay/questions/proxies/index.ts +0 -2
- package/src/screenplay/questions/proxies/key.ts +0 -14
- package/src/screenplay/tasks/Loop.ts +0 -240
- package/src/screenplay/tasks/index.ts +0 -1
- package/src/stage/DressingRoom.ts +0 -53
- package/src/stage/WithStage.ts +0 -52
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @desc
|
|
3
|
-
* Describes a collection providing
|
|
4
|
-
* a [`reduce`-like interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
|
|
5
|
-
*
|
|
6
|
-
* @interface
|
|
7
|
-
*
|
|
8
|
-
* @see {@link ElementArrayFinder}
|
|
9
|
-
* @see {@link Loop}
|
|
10
|
-
*/
|
|
11
|
-
export interface Reducible {
|
|
12
|
-
/**
|
|
13
|
-
* @type {function<T,A>(callback: (accumulator: A, currentValue: T, index: number) => A, initialValue: A): PromiseLike<A> | A}
|
|
14
|
-
*/
|
|
15
|
-
reduce: <T, A>(fn: (accumulator: A, currentValue: T, index: number) => A, initialValue: A) => PromiseLike<A> | A;
|
|
16
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reducible.js","sourceRoot":"","sources":["../../../src/io/collections/reducible.ts"],"names":[],"mappings":""}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AnswersQuestions, Interaction, Question } from '..';
|
|
2
|
-
export declare type Assertion<A> = (actual: A) => void;
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated
|
|
5
|
-
* Use the <a href="/modules/assertions"><code>@serenity-js/assertions</code> module</a> instead
|
|
6
|
-
*/
|
|
7
|
-
export declare class See<S> extends Interaction {
|
|
8
|
-
private question;
|
|
9
|
-
private assert;
|
|
10
|
-
static if<T>(question: Question<T>, assertion: Assertion<T>): Interaction;
|
|
11
|
-
constructor(question: Question<S>, assert: Assertion<S>);
|
|
12
|
-
/**
|
|
13
|
-
* @desc
|
|
14
|
-
* Makes the provided {@link Actor}
|
|
15
|
-
* perform this {@link Interaction}.
|
|
16
|
-
*
|
|
17
|
-
* @param {AnswersQuestions} actor
|
|
18
|
-
* @returns {Promise<void>}
|
|
19
|
-
*
|
|
20
|
-
* @see {@link Actor}
|
|
21
|
-
* @see {@link AnswersQuestions}
|
|
22
|
-
*/
|
|
23
|
-
performAs(actor: AnswersQuestions): PromiseLike<void>;
|
|
24
|
-
/**
|
|
25
|
-
* @desc
|
|
26
|
-
* Generates a description to be used when reporting this {@link Activity}.
|
|
27
|
-
*
|
|
28
|
-
* @returns {string}
|
|
29
|
-
*/
|
|
30
|
-
toString(): string;
|
|
31
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.See = void 0;
|
|
4
|
-
const __1 = require("..");
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated
|
|
7
|
-
* Use the <a href="/modules/assertions"><code>@serenity-js/assertions</code> module</a> instead
|
|
8
|
-
*/
|
|
9
|
-
class See extends __1.Interaction {
|
|
10
|
-
constructor(question, assert) {
|
|
11
|
-
super();
|
|
12
|
-
this.question = question;
|
|
13
|
-
this.assert = assert;
|
|
14
|
-
}
|
|
15
|
-
static if(question, assertion) {
|
|
16
|
-
return new See(question, assertion);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @desc
|
|
20
|
-
* Makes the provided {@link Actor}
|
|
21
|
-
* perform this {@link Interaction}.
|
|
22
|
-
*
|
|
23
|
-
* @param {AnswersQuestions} actor
|
|
24
|
-
* @returns {Promise<void>}
|
|
25
|
-
*
|
|
26
|
-
* @see {@link Actor}
|
|
27
|
-
* @see {@link AnswersQuestions}
|
|
28
|
-
*/
|
|
29
|
-
performAs(actor) {
|
|
30
|
-
return actor.answer(this.question).then(this.assert);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @desc
|
|
34
|
-
* Generates a description to be used when reporting this {@link Activity}.
|
|
35
|
-
*
|
|
36
|
-
* @returns {string}
|
|
37
|
-
*/
|
|
38
|
-
toString() {
|
|
39
|
-
return `#actor checks ${this.question}`;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.See = See;
|
|
43
|
-
//# sourceMappingURL=See.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"See.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/See.ts"],"names":[],"mappings":";;;AAAA,0BAA6D;AAI7D;;;GAGG;AACH,MAAa,GAAO,SAAQ,eAAW;IAKnC,YACY,QAAqB,EACrB,MAAoB;QAE5B,KAAK,EAAE,CAAC;QAHA,aAAQ,GAAR,QAAQ,CAAa;QACrB,WAAM,GAAN,MAAM,CAAc;IAGhC,CAAC;IATD,MAAM,CAAC,EAAE,CAAI,QAAqB,EAAE,SAAuB;QACvD,OAAO,IAAI,GAAG,CAAI,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC3C,CAAC;IASD;;;;;;;;;;OAUG;IACH,SAAS,CAAC,KAAuB;QAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACJ,OAAO,iBAAiB,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC5C,CAAC;CACJ;AApCD,kBAoCC"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Answerable } from '../Answerable';
|
|
2
|
-
import { WithPropertiesAsMetaQuestions, WithPropertiesAsQuestions } from './proxies';
|
|
3
|
-
/**
|
|
4
|
-
* @desc
|
|
5
|
-
* Enables easy access to properties of the value of a given {@link Answerable}.
|
|
6
|
-
*
|
|
7
|
-
* @example <caption>Example API response</caption>
|
|
8
|
-
* interface EnvironmentDetails {
|
|
9
|
-
* name: string;
|
|
10
|
-
* url: string;
|
|
11
|
-
* }
|
|
12
|
-
*
|
|
13
|
-
* interface EnvironmentsResponse {
|
|
14
|
-
* environments: EnvironmentDetails[];
|
|
15
|
-
* }
|
|
16
|
-
*
|
|
17
|
-
* const response: EnvironmentsResponse = {
|
|
18
|
-
* "environments": [
|
|
19
|
-
* {
|
|
20
|
-
* "name": "dev",
|
|
21
|
-
* "url": "https://dev.example.com"
|
|
22
|
-
* },
|
|
23
|
-
* {
|
|
24
|
-
* "name": "sit",
|
|
25
|
-
* "url": "https://sit.example.com"
|
|
26
|
-
* }
|
|
27
|
-
* ]
|
|
28
|
-
* }
|
|
29
|
-
*
|
|
30
|
-
* @example <caption>Combining Property.of and Property.at</caption>
|
|
31
|
-
* import { actorCalled, List, Property } from '@serenity-js/core';
|
|
32
|
-
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
33
|
-
*
|
|
34
|
-
* actorCalled('Lisa').attemptsTo(
|
|
35
|
-
* Ensure.that(
|
|
36
|
-
* Property.of(
|
|
37
|
-
* List.of(response.environments)
|
|
38
|
-
* .where(Property.at<EnvironmentDetails>().name, equals('dev'))
|
|
39
|
-
* .first(),
|
|
40
|
-
* ).url,
|
|
41
|
-
* equals('https://dev.example.com')
|
|
42
|
-
* )
|
|
43
|
-
* )
|
|
44
|
-
*
|
|
45
|
-
* @see {@link Question}
|
|
46
|
-
* @see {@link List}
|
|
47
|
-
*/
|
|
48
|
-
export declare class Property {
|
|
49
|
-
/**
|
|
50
|
-
* @desc
|
|
51
|
-
* Generates a {@link Proxy} around a given {@link Answerable} `subject`
|
|
52
|
-
* to turn the properties of the value it will resolve to into {@link Question}s.
|
|
53
|
-
*
|
|
54
|
-
* @example <caption>Reading a property</caption>
|
|
55
|
-
* import { actorCalled, Property } from '@serenity-js/core';
|
|
56
|
-
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
57
|
-
*
|
|
58
|
-
* actorCalled('Lisa').attemptsTo(
|
|
59
|
-
* Ensure.that(
|
|
60
|
-
* Property.of(response).environments[0].name,
|
|
61
|
-
* equals('dev')
|
|
62
|
-
* )
|
|
63
|
-
* )
|
|
64
|
-
*
|
|
65
|
-
* @param {Answerable<Subject>} subject
|
|
66
|
-
* @returns {Proxy<Subject>}
|
|
67
|
-
*/
|
|
68
|
-
static of<Subject extends object>(subject: Answerable<Subject>): WithPropertiesAsQuestions<Subject>;
|
|
69
|
-
/**
|
|
70
|
-
* @desc
|
|
71
|
-
* Generates a {@link Proxy} around a given {@link Answerable} `subject`
|
|
72
|
-
* to turn any of its properties into {@link MetaQuestion}s
|
|
73
|
-
* to be used when filtering a {@link List},
|
|
74
|
-
*
|
|
75
|
-
* @example <caption>Reading a property</caption>
|
|
76
|
-
* import { actorCalled, Property } from '@serenity-js/core';
|
|
77
|
-
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
78
|
-
*
|
|
79
|
-
* actorCalled('Lisa').attemptsTo(
|
|
80
|
-
* Ensure.that(
|
|
81
|
-
* List.of(response.environments)
|
|
82
|
-
* .where(Property.at<EnvironmentDetails>().name, equals('dev'))
|
|
83
|
-
* .first(),
|
|
84
|
-
* equals(response.environments[0])
|
|
85
|
-
* )
|
|
86
|
-
* )
|
|
87
|
-
*
|
|
88
|
-
* @returns {Proxy<Subject>}
|
|
89
|
-
*/
|
|
90
|
-
static at<Subject extends object>(): WithPropertiesAsMetaQuestions<Subject>;
|
|
91
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Property = void 0;
|
|
4
|
-
const proxies_1 = require("./proxies");
|
|
5
|
-
/**
|
|
6
|
-
* @desc
|
|
7
|
-
* Enables easy access to properties of the value of a given {@link Answerable}.
|
|
8
|
-
*
|
|
9
|
-
* @example <caption>Example API response</caption>
|
|
10
|
-
* interface EnvironmentDetails {
|
|
11
|
-
* name: string;
|
|
12
|
-
* url: string;
|
|
13
|
-
* }
|
|
14
|
-
*
|
|
15
|
-
* interface EnvironmentsResponse {
|
|
16
|
-
* environments: EnvironmentDetails[];
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* const response: EnvironmentsResponse = {
|
|
20
|
-
* "environments": [
|
|
21
|
-
* {
|
|
22
|
-
* "name": "dev",
|
|
23
|
-
* "url": "https://dev.example.com"
|
|
24
|
-
* },
|
|
25
|
-
* {
|
|
26
|
-
* "name": "sit",
|
|
27
|
-
* "url": "https://sit.example.com"
|
|
28
|
-
* }
|
|
29
|
-
* ]
|
|
30
|
-
* }
|
|
31
|
-
*
|
|
32
|
-
* @example <caption>Combining Property.of and Property.at</caption>
|
|
33
|
-
* import { actorCalled, List, Property } from '@serenity-js/core';
|
|
34
|
-
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
35
|
-
*
|
|
36
|
-
* actorCalled('Lisa').attemptsTo(
|
|
37
|
-
* Ensure.that(
|
|
38
|
-
* Property.of(
|
|
39
|
-
* List.of(response.environments)
|
|
40
|
-
* .where(Property.at<EnvironmentDetails>().name, equals('dev'))
|
|
41
|
-
* .first(),
|
|
42
|
-
* ).url,
|
|
43
|
-
* equals('https://dev.example.com')
|
|
44
|
-
* )
|
|
45
|
-
* )
|
|
46
|
-
*
|
|
47
|
-
* @see {@link Question}
|
|
48
|
-
* @see {@link List}
|
|
49
|
-
*/
|
|
50
|
-
class Property {
|
|
51
|
-
/**
|
|
52
|
-
* @desc
|
|
53
|
-
* Generates a {@link Proxy} around a given {@link Answerable} `subject`
|
|
54
|
-
* to turn the properties of the value it will resolve to into {@link Question}s.
|
|
55
|
-
*
|
|
56
|
-
* @example <caption>Reading a property</caption>
|
|
57
|
-
* import { actorCalled, Property } from '@serenity-js/core';
|
|
58
|
-
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
59
|
-
*
|
|
60
|
-
* actorCalled('Lisa').attemptsTo(
|
|
61
|
-
* Ensure.that(
|
|
62
|
-
* Property.of(response).environments[0].name,
|
|
63
|
-
* equals('dev')
|
|
64
|
-
* )
|
|
65
|
-
* )
|
|
66
|
-
*
|
|
67
|
-
* @param {Answerable<Subject>} subject
|
|
68
|
-
* @returns {Proxy<Subject>}
|
|
69
|
-
*/
|
|
70
|
-
static of(subject) {
|
|
71
|
-
return (0, proxies_1.createQuestionProxy)(subject);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* @desc
|
|
75
|
-
* Generates a {@link Proxy} around a given {@link Answerable} `subject`
|
|
76
|
-
* to turn any of its properties into {@link MetaQuestion}s
|
|
77
|
-
* to be used when filtering a {@link List},
|
|
78
|
-
*
|
|
79
|
-
* @example <caption>Reading a property</caption>
|
|
80
|
-
* import { actorCalled, Property } from '@serenity-js/core';
|
|
81
|
-
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
82
|
-
*
|
|
83
|
-
* actorCalled('Lisa').attemptsTo(
|
|
84
|
-
* Ensure.that(
|
|
85
|
-
* List.of(response.environments)
|
|
86
|
-
* .where(Property.at<EnvironmentDetails>().name, equals('dev'))
|
|
87
|
-
* .first(),
|
|
88
|
-
* equals(response.environments[0])
|
|
89
|
-
* )
|
|
90
|
-
* )
|
|
91
|
-
*
|
|
92
|
-
* @returns {Proxy<Subject>}
|
|
93
|
-
*/
|
|
94
|
-
static at() {
|
|
95
|
-
return (0, proxies_1.createMetaQuestionProxy)();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
exports.Property = Property;
|
|
99
|
-
//# sourceMappingURL=Property.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Property.js","sourceRoot":"","sources":["../../../src/screenplay/questions/Property.ts"],"names":[],"mappings":";;;AACA,uCAAmI;AAEnI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAa,QAAQ;IAEjB;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,EAAE,CAAyB,OAA4B;QAC1D,OAAO,IAAA,6BAAmB,EAAU,OAAO,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,EAAE;QACL,OAAO,IAAA,iCAAuB,GAAW,CAAC;IAC9C,CAAC;CACJ;AAjDD,4BAiDC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AnswersQuestions, UsesAbilities } from '../actor';
|
|
2
|
-
import { Answerable } from '../Answerable';
|
|
3
|
-
import { Question } from '../Question';
|
|
4
|
-
/**
|
|
5
|
-
* @experimental
|
|
6
|
-
*/
|
|
7
|
-
export declare class Transform<Answer_Type extends any, Output_Type> extends Question<Promise<Output_Type>> {
|
|
8
|
-
private readonly questions;
|
|
9
|
-
private readonly transformation;
|
|
10
|
-
private readonly description;
|
|
11
|
-
static the<AT extends any, OT>(questions: Answerable<AT> | Array<Answerable<AT>>, transformation: (...answers: AT[]) => OT): Transform<AT, OT>;
|
|
12
|
-
constructor(questions: Array<Answerable<Answer_Type>>, transformation: (...answers: Answer_Type[]) => Output_Type, description?: string);
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated
|
|
15
|
-
* Please use {@link Transform#describedAs} instead
|
|
16
|
-
*
|
|
17
|
-
* @desc
|
|
18
|
-
* Overrides the default {@link Transform#toString} representation of this object.
|
|
19
|
-
*
|
|
20
|
-
* @param {string} description
|
|
21
|
-
* @returns {Transform<Answer_Type, Output_Type>}
|
|
22
|
-
*/
|
|
23
|
-
as(description: string): Transform<Answer_Type, Output_Type>;
|
|
24
|
-
/**
|
|
25
|
-
* Changes the description of this question's subject.
|
|
26
|
-
*
|
|
27
|
-
* @param subject
|
|
28
|
-
*/
|
|
29
|
-
describedAs(subject: string): this;
|
|
30
|
-
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<Output_Type>;
|
|
31
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Transform = void 0;
|
|
4
|
-
const Question_1 = require("../Question");
|
|
5
|
-
/**
|
|
6
|
-
* @experimental
|
|
7
|
-
*/
|
|
8
|
-
class Transform extends Question_1.Question {
|
|
9
|
-
constructor(questions, transformation, description = `a transformed answer`) {
|
|
10
|
-
super(description);
|
|
11
|
-
this.questions = questions;
|
|
12
|
-
this.transformation = transformation;
|
|
13
|
-
this.description = description;
|
|
14
|
-
}
|
|
15
|
-
static the(questions, transformation) {
|
|
16
|
-
return new Transform([].concat(questions), transformation);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated
|
|
20
|
-
* Please use {@link Transform#describedAs} instead
|
|
21
|
-
*
|
|
22
|
-
* @desc
|
|
23
|
-
* Overrides the default {@link Transform#toString} representation of this object.
|
|
24
|
-
*
|
|
25
|
-
* @param {string} description
|
|
26
|
-
* @returns {Transform<Answer_Type, Output_Type>}
|
|
27
|
-
*/
|
|
28
|
-
as(description) {
|
|
29
|
-
return this.describedAs(description);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Changes the description of this question's subject.
|
|
33
|
-
*
|
|
34
|
-
* @param subject
|
|
35
|
-
*/
|
|
36
|
-
describedAs(subject) {
|
|
37
|
-
this.subject = subject;
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
answeredBy(actor) {
|
|
41
|
-
return Promise.all(this.questions.map(question => actor.answer(question)))
|
|
42
|
-
.then(answers => this.transformation(...answers));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.Transform = Transform;
|
|
46
|
-
//# sourceMappingURL=Transform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Transform.js","sourceRoot":"","sources":["../../../src/screenplay/questions/Transform.ts"],"names":[],"mappings":";;;AAGA,0CAAuC;AAEvC;;GAEG;AACH,MAAa,SAAgD,SAAQ,mBAA8B;IAK/F,YACqB,SAAyC,EACzC,cAA0D,EAC1D,cAAsB,sBAAsB;QAE7D,KAAK,CAAC,WAAW,CAAC,CAAC;QAJF,cAAS,GAAT,SAAS,CAAgC;QACzC,mBAAc,GAAd,cAAc,CAA4C;QAC1D,gBAAW,GAAX,WAAW,CAAiC;IAGjE,CAAC;IAVD,MAAM,CAAC,GAAG,CAAqB,SAAiD,EAAE,cAAwC;QACtH,OAAO,IAAI,SAAS,CAAS,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC,CAAC;IACvE,CAAC;IAUD;;;;;;;;;OASG;IACH,EAAE,CAAC,WAAmB;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,OAAe;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,KAAuC;QAC9C,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;aACrE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAC1D,CAAC;CACJ;AA1CD,8BA0CC"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { AnswersQuestions, UsesAbilities } from '../../actor';
|
|
2
|
-
import { Answerable } from '../../Answerable';
|
|
3
|
-
import { Expectation } from '../Expectation';
|
|
4
|
-
import { MetaQuestion } from '../MetaQuestion';
|
|
5
|
-
import { ListAdapter } from './ListAdapter';
|
|
6
|
-
/**
|
|
7
|
-
* @desc
|
|
8
|
-
* Adapts an {@link Array} so that it can be used with {@link List}
|
|
9
|
-
*
|
|
10
|
-
* @implements {ListAdapter}
|
|
11
|
-
*/
|
|
12
|
-
export declare class ArrayListAdapter<Item_Type> implements ListAdapter<Item_Type, Item_Type[], Promise<Item_Type>, Promise<Item_Type[]>> {
|
|
13
|
-
private readonly array;
|
|
14
|
-
/**
|
|
15
|
-
* @param {Answerable<Item_Type[]>} array
|
|
16
|
-
*/
|
|
17
|
-
constructor(array: Answerable<Item_Type[]>);
|
|
18
|
-
/**
|
|
19
|
-
* @desc
|
|
20
|
-
* Returns the number of items the underlying {@link Array} contains,
|
|
21
|
-
* left after applying any filters.
|
|
22
|
-
*
|
|
23
|
-
* @param {AnswersQuestions & UsesAbilities} actor
|
|
24
|
-
* @returns {Promise<number>}
|
|
25
|
-
*/
|
|
26
|
-
count(actor: AnswersQuestions & UsesAbilities): Promise<number>;
|
|
27
|
-
/**
|
|
28
|
-
* @desc
|
|
29
|
-
* Returns the underlying {@link Array},
|
|
30
|
-
* with any filters applied.
|
|
31
|
-
*
|
|
32
|
-
* @param {AnswersQuestions & UsesAbilities} actor
|
|
33
|
-
* @returns {Promise<number>}
|
|
34
|
-
*/
|
|
35
|
-
items(actor: AnswersQuestions & UsesAbilities): Promise<Item_Type[]>;
|
|
36
|
-
/**
|
|
37
|
-
* @desc
|
|
38
|
-
* Returns the first of items the underlying {@link Array} contains,
|
|
39
|
-
* left after applying any filters.
|
|
40
|
-
*
|
|
41
|
-
* @param {AnswersQuestions & UsesAbilities} actor
|
|
42
|
-
* @returns {Promise<Item_Type>}
|
|
43
|
-
*/
|
|
44
|
-
first(actor: AnswersQuestions & UsesAbilities): Promise<Item_Type>;
|
|
45
|
-
/**
|
|
46
|
-
* @desc
|
|
47
|
-
* Returns the nth of items the underlying {@link Array} contains,
|
|
48
|
-
* left after applying any filters.
|
|
49
|
-
*
|
|
50
|
-
* @param {AnswersQuestions & UsesAbilities} actor
|
|
51
|
-
*
|
|
52
|
-
* @param {number} index
|
|
53
|
-
* Zero-based index of the item to return
|
|
54
|
-
*
|
|
55
|
-
* @returns {Promise<Item_Type>}
|
|
56
|
-
*/
|
|
57
|
-
get(actor: AnswersQuestions & UsesAbilities, index: number): Promise<Item_Type>;
|
|
58
|
-
/**
|
|
59
|
-
* @desc
|
|
60
|
-
* Returns the last of items the underlying {@link Array} contains,
|
|
61
|
-
* left after applying any filters.
|
|
62
|
-
*
|
|
63
|
-
* @param {AnswersQuestions & UsesAbilities} actor
|
|
64
|
-
* @returns {Promise<Item_Type>}
|
|
65
|
-
*/
|
|
66
|
-
last(actor: AnswersQuestions & UsesAbilities): Promise<Item_Type>;
|
|
67
|
-
/**
|
|
68
|
-
* @desc
|
|
69
|
-
* Filters the underlying {@link Array} so that the result contains only those items that meet the {@link Expectation}
|
|
70
|
-
*
|
|
71
|
-
* @param {MetaQuestion<Item_Type, Promise<Answer_Type> | Answer_Type>} question
|
|
72
|
-
* @param {Expectation<any, Answer_Type>} expectation
|
|
73
|
-
*
|
|
74
|
-
* @returns {ListAdapter<Item_Type, Item_Type[], Promise<Item_Type>, Promise<Item_Type[]>>}
|
|
75
|
-
*
|
|
76
|
-
* @see {MetaQuestion}
|
|
77
|
-
*/
|
|
78
|
-
withFilter<Answer_Type>(question: MetaQuestion<Item_Type, Promise<Answer_Type> | Answer_Type>, expectation: Expectation<any, Answer_Type>): ListAdapter<Item_Type, Item_Type[], Promise<Item_Type>, Promise<Item_Type[]>>;
|
|
79
|
-
/**
|
|
80
|
-
* @desc
|
|
81
|
-
* Returns a human-readable description of the underlying {@link Array}.
|
|
82
|
-
*
|
|
83
|
-
* @returns {string}
|
|
84
|
-
*/
|
|
85
|
-
toString(): string;
|
|
86
|
-
private arrayAs;
|
|
87
|
-
private getItemAt;
|
|
88
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayListAdapter = void 0;
|
|
4
|
-
const tiny_types_1 = require("tiny-types");
|
|
5
|
-
const io_1 = require("../../../io");
|
|
6
|
-
const Question_1 = require("../../Question");
|
|
7
|
-
const expectations_1 = require("../expectations");
|
|
8
|
-
/**
|
|
9
|
-
* @desc
|
|
10
|
-
* Adapts an {@link Array} so that it can be used with {@link List}
|
|
11
|
-
*
|
|
12
|
-
* @implements {ListAdapter}
|
|
13
|
-
*/
|
|
14
|
-
class ArrayListAdapter {
|
|
15
|
-
/**
|
|
16
|
-
* @param {Answerable<Item_Type[]>} array
|
|
17
|
-
*/
|
|
18
|
-
constructor(array) {
|
|
19
|
-
this.array = array;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @desc
|
|
23
|
-
* Returns the number of items the underlying {@link Array} contains,
|
|
24
|
-
* left after applying any filters.
|
|
25
|
-
*
|
|
26
|
-
* @param {AnswersQuestions & UsesAbilities} actor
|
|
27
|
-
* @returns {Promise<number>}
|
|
28
|
-
*/
|
|
29
|
-
count(actor) {
|
|
30
|
-
return this.arrayAs(actor)
|
|
31
|
-
.then(items => items.length);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @desc
|
|
35
|
-
* Returns the underlying {@link Array},
|
|
36
|
-
* with any filters applied.
|
|
37
|
-
*
|
|
38
|
-
* @param {AnswersQuestions & UsesAbilities} actor
|
|
39
|
-
* @returns {Promise<number>}
|
|
40
|
-
*/
|
|
41
|
-
items(actor) {
|
|
42
|
-
return this.arrayAs(actor);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @desc
|
|
46
|
-
* Returns the first of items the underlying {@link Array} contains,
|
|
47
|
-
* left after applying any filters.
|
|
48
|
-
*
|
|
49
|
-
* @param {AnswersQuestions & UsesAbilities} actor
|
|
50
|
-
* @returns {Promise<Item_Type>}
|
|
51
|
-
*/
|
|
52
|
-
first(actor) {
|
|
53
|
-
return this.arrayAs(actor)
|
|
54
|
-
.then(items => this.getItemAt(items, 0));
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* @desc
|
|
58
|
-
* Returns the nth of items the underlying {@link Array} contains,
|
|
59
|
-
* left after applying any filters.
|
|
60
|
-
*
|
|
61
|
-
* @param {AnswersQuestions & UsesAbilities} actor
|
|
62
|
-
*
|
|
63
|
-
* @param {number} index
|
|
64
|
-
* Zero-based index of the item to return
|
|
65
|
-
*
|
|
66
|
-
* @returns {Promise<Item_Type>}
|
|
67
|
-
*/
|
|
68
|
-
get(actor, index) {
|
|
69
|
-
return this.arrayAs(actor)
|
|
70
|
-
.then(items => this.getItemAt(items, index));
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* @desc
|
|
74
|
-
* Returns the last of items the underlying {@link Array} contains,
|
|
75
|
-
* left after applying any filters.
|
|
76
|
-
*
|
|
77
|
-
* @param {AnswersQuestions & UsesAbilities} actor
|
|
78
|
-
* @returns {Promise<Item_Type>}
|
|
79
|
-
*/
|
|
80
|
-
last(actor) {
|
|
81
|
-
return this.arrayAs(actor)
|
|
82
|
-
.then(items => this.getItemAt(items, items.length - 1));
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* @desc
|
|
86
|
-
* Filters the underlying {@link Array} so that the result contains only those items that meet the {@link Expectation}
|
|
87
|
-
*
|
|
88
|
-
* @param {MetaQuestion<Item_Type, Promise<Answer_Type> | Answer_Type>} question
|
|
89
|
-
* @param {Expectation<any, Answer_Type>} expectation
|
|
90
|
-
*
|
|
91
|
-
* @returns {ListAdapter<Item_Type, Item_Type[], Promise<Item_Type>, Promise<Item_Type[]>>}
|
|
92
|
-
*
|
|
93
|
-
* @see {MetaQuestion}
|
|
94
|
-
*/
|
|
95
|
-
withFilter(question, expectation) {
|
|
96
|
-
return new ArrayListAdapter(new ArrayListFilter(this.array, question, expectation));
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* @desc
|
|
100
|
-
* Returns a human-readable description of the underlying {@link Array}.
|
|
101
|
-
*
|
|
102
|
-
* @returns {string}
|
|
103
|
-
*/
|
|
104
|
-
toString() {
|
|
105
|
-
return (0, io_1.formatted) `${this.array}`;
|
|
106
|
-
}
|
|
107
|
-
arrayAs(actor) {
|
|
108
|
-
return actor.answer(this.array)
|
|
109
|
-
.then(array => (0, tiny_types_1.ensure)('ArrayListAdapter constructor parameter', array, (0, tiny_types_1.isArray)()));
|
|
110
|
-
}
|
|
111
|
-
getItemAt(items, index) {
|
|
112
|
-
(0, tiny_types_1.ensure)('index', index, (0, tiny_types_1.isNumber)());
|
|
113
|
-
const collectionDescription = this.toString();
|
|
114
|
-
const itemsDescription = (0, io_1.formatted) `${items}`;
|
|
115
|
-
const description = collectionDescription !== itemsDescription
|
|
116
|
-
? `${collectionDescription} ${itemsDescription}`
|
|
117
|
-
: itemsDescription;
|
|
118
|
-
if (items.length === 0) {
|
|
119
|
-
throw new Error(`${description} is empty`);
|
|
120
|
-
}
|
|
121
|
-
if (index in items) {
|
|
122
|
-
return items[index];
|
|
123
|
-
}
|
|
124
|
-
throw new Error(`${description} has no item at index ${index}`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.ArrayListAdapter = ArrayListAdapter;
|
|
128
|
-
/**
|
|
129
|
-
* @package
|
|
130
|
-
*/
|
|
131
|
-
class ArrayListFilter extends Question_1.Question {
|
|
132
|
-
constructor(collection, question, expectation) {
|
|
133
|
-
super([
|
|
134
|
-
(0, io_1.formatted) `${collection}`,
|
|
135
|
-
collection instanceof ArrayListFilter ? 'and' : 'where',
|
|
136
|
-
(0, io_1.formatted) `${question} does ${expectation}`
|
|
137
|
-
].join(' '));
|
|
138
|
-
this.collection = collection;
|
|
139
|
-
this.question = question;
|
|
140
|
-
this.expectation = expectation;
|
|
141
|
-
}
|
|
142
|
-
answeredBy(actor) {
|
|
143
|
-
return actor.answer(this.collection)
|
|
144
|
-
.then(array => (0, tiny_types_1.ensure)('ArrayListAdapter constructor parameter', array, (0, tiny_types_1.isArray)())) // todo: extract to avoid duplication?
|
|
145
|
-
.then(array => Promise.all(array.map(item => Promise.resolve(this.question.of(item).answeredBy(actor))
|
|
146
|
-
.then(answer => this.expectation.answeredBy(actor)(answer))
|
|
147
|
-
.then(outcome => ({ item, outcome })))))
|
|
148
|
-
.then(results => results.filter(result => result.outcome instanceof expectations_1.ExpectationMet)
|
|
149
|
-
.map(result => result.item));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
//# sourceMappingURL=ArrayListAdapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayListAdapter.js","sourceRoot":"","sources":["../../../../src/screenplay/questions/lists/ArrayListAdapter.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AnswersQuestions, UsesAbilities } from '../../actor';
|
|
2
|
-
import { Expectation } from '../Expectation';
|
|
3
|
-
import { MetaQuestion } from '../MetaQuestion';
|
|
4
|
-
/**
|
|
5
|
-
* @desc
|
|
6
|
-
* Adapts various types of collections so that they can be used with {@link List}.
|
|
7
|
-
*
|
|
8
|
-
* You probably won't need to implement this interface, unless you're extending Serenity/JS.
|
|
9
|
-
*
|
|
10
|
-
* @see {@link List}
|
|
11
|
-
*/
|
|
12
|
-
export interface ListAdapter<Item_Type, Collection_Type, Item_Return_Type = Item_Type, Collection_Return_Type = Collection_Type> {
|
|
13
|
-
count(actor: AnswersQuestions & UsesAbilities): Promise<number>;
|
|
14
|
-
first(actor: AnswersQuestions & UsesAbilities): Item_Return_Type;
|
|
15
|
-
last(actor: AnswersQuestions & UsesAbilities): Item_Return_Type;
|
|
16
|
-
get(actor: AnswersQuestions & UsesAbilities, index: number): Item_Return_Type;
|
|
17
|
-
items(actor: AnswersQuestions & UsesAbilities): Collection_Return_Type;
|
|
18
|
-
withFilter<Answer_Type>(question: MetaQuestion<Item_Type, Promise<Answer_Type> | Answer_Type>, expectation: Expectation<any, Answer_Type>): ListAdapter<Item_Type, Collection_Type, Item_Return_Type, Collection_Return_Type>;
|
|
19
|
-
toString(): string;
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListAdapter.js","sourceRoot":"","sources":["../../../../src/screenplay/questions/lists/ListAdapter.ts"],"names":[],"mappings":""}
|