@serenity-js/core 2.32.5 → 3.0.0-rc.4
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 +79 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -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/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 +37 -0
- package/lib/io/format.js +49 -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 +50 -14
- 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/Question.d.ts +6 -83
- package/lib/screenplay/Question.js +14 -98
- 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/model/Adapter.d.ts +8 -0
- package/lib/{io/collections/reducible.js → screenplay/model/Adapter.js} +1 -1
- package/lib/screenplay/model/Adapter.js.map +1 -0
- package/lib/screenplay/model/createAdapter.d.ts +3 -0
- package/lib/screenplay/model/createAdapter.js +118 -0
- package/lib/screenplay/model/createAdapter.js.map +1 -0
- package/lib/screenplay/model/index.d.ts +2 -0
- package/lib/screenplay/{tasks → model}/index.js +2 -1
- package/lib/screenplay/model/index.js.map +1 -0
- package/lib/screenplay/questions/Expectation.d.ts +11 -0
- package/lib/screenplay/questions/Expectation.js +18 -1
- package/lib/screenplay/questions/Expectation.js.map +1 -1
- package/lib/screenplay/questions/List.d.ts +22 -191
- package/lib/screenplay/questions/List.js +162 -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/package.json +6 -6
- package/src/index.ts +2 -1
- package/src/io/ErrorSerialiser.ts +5 -1
- package/src/io/asyncMap.ts +18 -0
- package/src/io/format.ts +46 -0
- package/src/io/formatted.ts +7 -15
- package/src/io/index.ts +2 -1
- package/src/io/inspected.ts +66 -14
- package/src/model/Timestamp.ts +10 -2
- package/src/screenplay/Question.ts +21 -119
- package/src/screenplay/actor/Actor.ts +2 -2
- package/src/screenplay/index.ts +1 -1
- package/src/screenplay/model/Adapter.ts +14 -0
- package/src/screenplay/model/createAdapter.ts +149 -0
- package/src/screenplay/model/index.ts +2 -0
- package/src/screenplay/questions/Expectation.ts +20 -1
- package/src/screenplay/questions/List.ts +228 -232
- package/src/screenplay/questions/Note.ts +21 -1
- package/src/screenplay/questions/index.ts +0 -3
- 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/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.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/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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatted } from '../../io';
|
|
1
2
|
import { TakeNotes } from '../abilities';
|
|
2
3
|
import { AnswersQuestions, UsesAbilities } from '../actor';
|
|
3
4
|
import { Question } from '../Question';
|
|
@@ -42,6 +43,8 @@ import { Question } from '../Question';
|
|
|
42
43
|
*/
|
|
43
44
|
export class Note<Answer> extends Question<Promise<Answer>> {
|
|
44
45
|
|
|
46
|
+
private subject: string;
|
|
47
|
+
|
|
45
48
|
/**
|
|
46
49
|
* @desc
|
|
47
50
|
* Retrieves the previously recorded answer to a given {@link Question}
|
|
@@ -58,7 +61,8 @@ export class Note<Answer> extends Question<Promise<Answer>> {
|
|
|
58
61
|
* @param {Question<Promise<Answer>> | Question<Answer> | string} topic
|
|
59
62
|
*/
|
|
60
63
|
constructor(private readonly topic: Question<Promise<Answer>> | Question<Answer> | string) {
|
|
61
|
-
super(
|
|
64
|
+
super();
|
|
65
|
+
this.subject = formatted `a note of ${ topic }`;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
/**
|
|
@@ -76,4 +80,20 @@ export class Note<Answer> extends Question<Promise<Answer>> {
|
|
|
76
80
|
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<Answer> {
|
|
77
81
|
return TakeNotes.as(actor).answerTo(this.topic);
|
|
78
82
|
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @desc
|
|
86
|
+
* Changes the description of this question's subject.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} subject
|
|
89
|
+
* @returns {Question<T>}
|
|
90
|
+
*/
|
|
91
|
+
describedAs(subject: string): this {
|
|
92
|
+
this.subject = subject;
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
toString(): string {
|
|
97
|
+
return this.subject;
|
|
98
|
+
}
|
|
79
99
|
}
|
|
@@ -2,9 +2,6 @@ export * from './Check';
|
|
|
2
2
|
export * from './Expectation';
|
|
3
3
|
export * from './expectations';
|
|
4
4
|
export * from './List';
|
|
5
|
-
export * from './mappings';
|
|
6
5
|
export * from './MetaQuestion';
|
|
7
6
|
export * from './Note';
|
|
8
|
-
export { Property } from './Property';
|
|
9
7
|
export * from './q';
|
|
10
|
-
export * from './Transform';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./mappable"), exports);
|
|
14
|
-
__exportStar(require("./reducible"), exports);
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/io/collections/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @desc
|
|
3
|
-
* Describes a collection providing
|
|
4
|
-
* a [`map`-like interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
|
|
5
|
-
*
|
|
6
|
-
* @interface
|
|
7
|
-
*
|
|
8
|
-
* @see {@link Question#map}
|
|
9
|
-
* @see {@link ElementArrayFinder}
|
|
10
|
-
*/
|
|
11
|
-
export interface Mappable<Item> {
|
|
12
|
-
/**
|
|
13
|
-
* @desc
|
|
14
|
-
* Applies a {@link MappingFunction} function to each element of a {@link Mappable} collection.
|
|
15
|
-
*
|
|
16
|
-
* The callback receives an item from the collection as the first argument
|
|
17
|
-
* and its index as the second argument.
|
|
18
|
-
*
|
|
19
|
-
* @abstract
|
|
20
|
-
*
|
|
21
|
-
* @type {function<U>(callback: (item?: Item, index?: number) => U): PromiseLike<U[]> | U[]}
|
|
22
|
-
*/
|
|
23
|
-
map: <U>(callback: (item?: Item, index?: number) => U) => PromiseLike<U[]> | U[];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* @desc
|
|
27
|
-
* A mapping function converting one type into another.
|
|
28
|
-
*
|
|
29
|
-
* @public
|
|
30
|
-
*
|
|
31
|
-
* @typedef {function(item?: V, index?: number) => Promise<O> | O} Mapping<V,O>
|
|
32
|
-
*/
|
|
33
|
-
export declare type MappingFunction<V, O> = (item?: V, index?: number) => O;
|
|
34
|
-
/**
|
|
35
|
-
* @desc
|
|
36
|
-
* Checks if the value is a {@link Mappable} collection of items.
|
|
37
|
-
*
|
|
38
|
-
* @example <caption>An Array</caption>
|
|
39
|
-
* import { Mappable } from '@serenity-js/core/lib/io';
|
|
40
|
-
*
|
|
41
|
-
* Mappable.isMappable([ 1, 2, 3 ]) === true
|
|
42
|
-
*
|
|
43
|
-
* @example <caption>Protractor's ElementArrayFinder</caption>
|
|
44
|
-
* import { Mappable } from '@serenity-js/core/lib/io';
|
|
45
|
-
* import { element } from 'protractor';
|
|
46
|
-
*
|
|
47
|
-
* Mappable.isMappable(element.all(by.tagName('li')) === true
|
|
48
|
-
*
|
|
49
|
-
* @param {Mappable<Item> | any} maybeCollection
|
|
50
|
-
* @returns {boolean}
|
|
51
|
-
*/
|
|
52
|
-
export declare function isMappable<Item>(maybeCollection: Mappable<Item> | any): maybeCollection is Mappable<Item>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isMappable = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @desc
|
|
6
|
-
* Checks if the value is a {@link Mappable} collection of items.
|
|
7
|
-
*
|
|
8
|
-
* @example <caption>An Array</caption>
|
|
9
|
-
* import { Mappable } from '@serenity-js/core/lib/io';
|
|
10
|
-
*
|
|
11
|
-
* Mappable.isMappable([ 1, 2, 3 ]) === true
|
|
12
|
-
*
|
|
13
|
-
* @example <caption>Protractor's ElementArrayFinder</caption>
|
|
14
|
-
* import { Mappable } from '@serenity-js/core/lib/io';
|
|
15
|
-
* import { element } from 'protractor';
|
|
16
|
-
*
|
|
17
|
-
* Mappable.isMappable(element.all(by.tagName('li')) === true
|
|
18
|
-
*
|
|
19
|
-
* @param {Mappable<Item> | any} maybeCollection
|
|
20
|
-
* @returns {boolean}
|
|
21
|
-
*/
|
|
22
|
-
function isMappable(maybeCollection) {
|
|
23
|
-
return !!maybeCollection
|
|
24
|
-
&& !!maybeCollection.map
|
|
25
|
-
&& typeof maybeCollection.map === 'function';
|
|
26
|
-
}
|
|
27
|
-
exports.isMappable = isMappable;
|
|
28
|
-
//# sourceMappingURL=mappable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mappable.js","sourceRoot":"","sources":["../../../src/io/collections/mappable.ts"],"names":[],"mappings":";;;AAqCA;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,UAAU,CAAO,eAAqC;IAClE,OAAO,CAAC,CAAE,eAAe;WAClB,CAAC,CAAE,eAAe,CAAC,GAAG;WACtB,OAAO,eAAe,CAAC,GAAG,KAAK,UAAU,CAAC;AACrD,CAAC;AAJD,gCAIC"}
|
|
@@ -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,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
|
-
}
|