@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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Answerable } from '../screenplay';
|
|
2
|
+
/**
|
|
3
|
+
* @desc
|
|
4
|
+
* A factory function returning a tag function that produces a human-readable description of a template containing one or more {@link Answerable}s.
|
|
5
|
+
*
|
|
6
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { format, Question } from '@serenity-js/core';
|
|
10
|
+
*
|
|
11
|
+
* const someQuestion = () =>
|
|
12
|
+
* Question.about('some question', actor => 'some value');
|
|
13
|
+
*
|
|
14
|
+
* format({ markQuestions: true }) `actor answers ${ question() }`;
|
|
15
|
+
* // returns: actor answers <<some question>>
|
|
16
|
+
*
|
|
17
|
+
* format({ markQuestions: false }) `actor answers ${ question() }`;
|
|
18
|
+
* // returns: actor answers <<some question>>
|
|
19
|
+
*
|
|
20
|
+
* @example <caption>Aliasing</caption>
|
|
21
|
+
* import { format, Question } from '@serenity-js/core';
|
|
22
|
+
*
|
|
23
|
+
* const f = format({ markQuestions: true });
|
|
24
|
+
*
|
|
25
|
+
* const someQuestion = () =>
|
|
26
|
+
* Question.about('some question', actor => 'some value');
|
|
27
|
+
*
|
|
28
|
+
* f `actor answers ${ question() }`;
|
|
29
|
+
* // produces: actor answers <<some question>>
|
|
30
|
+
*
|
|
31
|
+
* @param {object} config
|
|
32
|
+
* - `markQuestions`: boolean - if set to true, descriptions of questions passed in as arguments will be surrounded with double angled brackets, i.e. `<<description>>`
|
|
33
|
+
* @returns {function(templates: TemplateStringsArray, placeholders: ...Array<Answerable<any>>): string}
|
|
34
|
+
*/
|
|
35
|
+
export declare function format(config: {
|
|
36
|
+
markQuestions: boolean;
|
|
37
|
+
}): (templates: TemplateStringsArray, ...placeholders: Array<Answerable<any>>) => string;
|
|
38
|
+
export declare const f: (templates: TemplateStringsArray, ...placeholders: Array<Answerable<any>>) => string;
|
|
39
|
+
export declare const d: (templates: TemplateStringsArray, ...placeholders: Array<Answerable<any>>) => string;
|
package/lib/io/format.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.d = exports.f = exports.format = void 0;
|
|
4
|
+
const inspected_1 = require("./inspected");
|
|
5
|
+
/**
|
|
6
|
+
* @desc
|
|
7
|
+
* A factory function returning a tag function that produces a human-readable description of a template containing one or more {@link Answerable}s.
|
|
8
|
+
*
|
|
9
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { format, Question } from '@serenity-js/core';
|
|
13
|
+
*
|
|
14
|
+
* const someQuestion = () =>
|
|
15
|
+
* Question.about('some question', actor => 'some value');
|
|
16
|
+
*
|
|
17
|
+
* format({ markQuestions: true }) `actor answers ${ question() }`;
|
|
18
|
+
* // returns: actor answers <<some question>>
|
|
19
|
+
*
|
|
20
|
+
* format({ markQuestions: false }) `actor answers ${ question() }`;
|
|
21
|
+
* // returns: actor answers <<some question>>
|
|
22
|
+
*
|
|
23
|
+
* @example <caption>Aliasing</caption>
|
|
24
|
+
* import { format, Question } from '@serenity-js/core';
|
|
25
|
+
*
|
|
26
|
+
* const f = format({ markQuestions: true });
|
|
27
|
+
*
|
|
28
|
+
* const someQuestion = () =>
|
|
29
|
+
* Question.about('some question', actor => 'some value');
|
|
30
|
+
*
|
|
31
|
+
* f `actor answers ${ question() }`;
|
|
32
|
+
* // produces: actor answers <<some question>>
|
|
33
|
+
*
|
|
34
|
+
* @param {object} config
|
|
35
|
+
* - `markQuestions`: boolean - if set to true, descriptions of questions passed in as arguments will be surrounded with double angled brackets, i.e. `<<description>>`
|
|
36
|
+
* @returns {function(templates: TemplateStringsArray, placeholders: ...Array<Answerable<any>>): string}
|
|
37
|
+
*/
|
|
38
|
+
function format(config) {
|
|
39
|
+
return (templates, ...placeholders) => {
|
|
40
|
+
return templates
|
|
41
|
+
.map((template, i) => i < placeholders.length
|
|
42
|
+
? [template, (0, inspected_1.inspected)(placeholders[i], { inline: true, markQuestions: config.markQuestions })]
|
|
43
|
+
: [template])
|
|
44
|
+
.reduce((acc, tuple) => acc.concat(tuple))
|
|
45
|
+
.join('');
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.format = format;
|
|
49
|
+
exports.f = format({ markQuestions: true });
|
|
50
|
+
exports.d = format({ markQuestions: false });
|
|
51
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/io/format.ts"],"names":[],"mappings":";;;AACA,2CAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,MAAM,CAAC,MAAkC;IACrD,OAAO,CAAC,SAA+B,EAAE,GAAG,YAAoC,EAAU,EAAE;QACxF,OAAO,SAAS;aACX,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM;YACzC,CAAC,CAAC,CAAE,QAAQ,EAAE,IAAA,qBAAS,EAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC,CAAE;YACjG,CAAC,CAAC,CAAE,QAAQ,CAAE,CAAC;aAClB,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;aACzC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC,CAAA;AACL,CAAC;AATD,wBASC;AAEY,QAAA,CAAC,GAAG,MAAM,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;AACpC,QAAA,CAAC,GAAG,MAAM,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC"}
|
package/lib/io/formatted.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Answerable } from '../screenplay
|
|
1
|
+
import { Answerable } from '../screenplay';
|
|
2
2
|
/**
|
|
3
3
|
* @desc
|
|
4
4
|
* A tag function returning a human-readable description of a template containing one or more {@link Answerable}s.
|
|
5
|
+
* This function is deprecated, please use {@link format} instead.
|
|
5
6
|
*
|
|
6
7
|
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
|
|
7
8
|
*
|
|
9
|
+
*
|
|
10
|
+
* @deprecated
|
|
11
|
+
*
|
|
8
12
|
* @param {TemplateStringsArray} templates
|
|
9
13
|
* @param {Array<Answerable<any>>} placeholders
|
|
10
14
|
* @returns {string}
|
package/lib/io/formatted.js
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatted = void 0;
|
|
4
|
-
const
|
|
4
|
+
const format_1 = require("./format");
|
|
5
5
|
/**
|
|
6
6
|
* @desc
|
|
7
7
|
* A tag function returning a human-readable description of a template containing one or more {@link Answerable}s.
|
|
8
|
+
* This function is deprecated, please use {@link format} instead.
|
|
8
9
|
*
|
|
9
10
|
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
|
|
10
11
|
*
|
|
12
|
+
*
|
|
13
|
+
* @deprecated
|
|
14
|
+
*
|
|
11
15
|
* @param {TemplateStringsArray} templates
|
|
12
16
|
* @param {Array<Answerable<any>>} placeholders
|
|
13
17
|
* @returns {string}
|
|
14
18
|
*/
|
|
15
19
|
function formatted(templates, ...placeholders) {
|
|
16
|
-
return templates
|
|
17
|
-
.map((template, i) => i < placeholders.length
|
|
18
|
-
? [template, compacted((0, inspected_1.inspected)(placeholders[i]))]
|
|
19
|
-
: [template])
|
|
20
|
-
.reduce((acc, tuple) => acc.concat(tuple))
|
|
21
|
-
.join('');
|
|
20
|
+
return (0, format_1.format)({ markQuestions: false })(templates, ...placeholders);
|
|
22
21
|
}
|
|
23
22
|
exports.formatted = formatted;
|
|
24
|
-
/** @private */
|
|
25
|
-
function compacted(multiline) {
|
|
26
|
-
return multiline
|
|
27
|
-
.replace(/\r?\n/g, ' ')
|
|
28
|
-
.replace(/\s+/g, ' ');
|
|
29
|
-
}
|
|
30
23
|
//# sourceMappingURL=formatted.js.map
|
package/lib/io/formatted.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatted.js","sourceRoot":"","sources":["../../src/io/formatted.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"formatted.js","sourceRoot":"","sources":["../../src/io/formatted.ts"],"names":[],"mappings":";;;AACA,qCAAkC;AAElC;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CAAC,SAA+B,EAAE,GAAG,YAAoC;IAC9F,OAAO,IAAA,eAAM,EAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,GAAG,YAAY,CAAC,CAAC;AACxE,CAAC;AAFD,8BAEC"}
|
package/lib/io/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './AssertionReportDiffer';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './asyncMap';
|
|
3
3
|
export * from './commaSeparated';
|
|
4
4
|
export * from './Config';
|
|
5
5
|
export * from './ErrorSerialiser';
|
|
@@ -7,6 +7,7 @@ export * from './ErrorStackParser';
|
|
|
7
7
|
export * from './FileFinder';
|
|
8
8
|
export * from './FileSystem';
|
|
9
9
|
export * from './FileSystemLocation';
|
|
10
|
+
export * from './format';
|
|
10
11
|
export * from './formatted';
|
|
11
12
|
export * from './json';
|
|
12
13
|
export * from './ModuleLoader';
|
package/lib/io/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./AssertionReportDiffer"), exports);
|
|
14
|
-
__exportStar(require("./
|
|
14
|
+
__exportStar(require("./asyncMap"), exports);
|
|
15
15
|
__exportStar(require("./commaSeparated"), exports);
|
|
16
16
|
__exportStar(require("./Config"), exports);
|
|
17
17
|
__exportStar(require("./ErrorSerialiser"), exports);
|
|
@@ -19,6 +19,7 @@ __exportStar(require("./ErrorStackParser"), exports);
|
|
|
19
19
|
__exportStar(require("./FileFinder"), exports);
|
|
20
20
|
__exportStar(require("./FileSystem"), exports);
|
|
21
21
|
__exportStar(require("./FileSystemLocation"), exports);
|
|
22
|
+
__exportStar(require("./format"), exports);
|
|
22
23
|
__exportStar(require("./formatted"), exports);
|
|
23
24
|
__exportStar(require("./json"), exports);
|
|
24
25
|
__exportStar(require("./ModuleLoader"), exports);
|
package/lib/io/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAwC;AACxC,6CAA2B;AAC3B,mDAAiC;AACjC,2CAAyB;AACzB,oDAAkC;AAClC,qDAAmC;AACnC,+CAA6B;AAC7B,+CAA6B;AAC7B,uDAAqC;AACrC,2CAAyB;AACzB,8CAA4B;AAC5B,yCAAuB;AACvB,iDAA+B;AAC/B,iDAA+B;AAC/B,yCAAuB;AACvB,+CAA6B;AAC7B,sDAAoC;AACpC,4CAA0B;AAC1B,4CAA0B"}
|
package/lib/io/inspected.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Answerable } from '../screenplay/Answerable';
|
|
2
|
+
interface InspectedConfig {
|
|
3
|
+
inline: boolean;
|
|
4
|
+
markQuestions?: boolean;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* @desc
|
|
4
8
|
* Provides a human-readable description of the {@link Answerable<T>}.
|
|
@@ -6,6 +10,10 @@ import { Answerable } from '../screenplay/Answerable';
|
|
|
6
10
|
*
|
|
7
11
|
* @public
|
|
8
12
|
* @param {Answerable<any>} value
|
|
13
|
+
* @param config
|
|
14
|
+
* - inline - Return a single-line string instead of the default potentially multi-line description
|
|
15
|
+
* - markQuestions - Surround the description of async values, such as Promises and Questions with <<value>>
|
|
9
16
|
* @return {string}
|
|
10
17
|
*/
|
|
11
|
-
export declare function inspected(value: Answerable<any
|
|
18
|
+
export declare function inspected(value: Answerable<any>, config?: InspectedConfig): string;
|
|
19
|
+
export {};
|
package/lib/io/inspected.js
CHANGED
|
@@ -10,24 +10,24 @@ const Question_1 = require("../screenplay/Question");
|
|
|
10
10
|
*
|
|
11
11
|
* @public
|
|
12
12
|
* @param {Answerable<any>} value
|
|
13
|
+
* @param config
|
|
14
|
+
* - inline - Return a single-line string instead of the default potentially multi-line description
|
|
15
|
+
* - markQuestions - Surround the description of async values, such as Promises and Questions with <<value>>
|
|
13
16
|
* @return {string}
|
|
14
17
|
*/
|
|
15
|
-
function inspected(value) {
|
|
18
|
+
function inspected(value, config) {
|
|
19
|
+
const { inline, markQuestions } = { inline: false, markQuestions: false, ...config };
|
|
16
20
|
if (!isDefined(value)) {
|
|
17
21
|
return (0, util_1.inspect)(value);
|
|
18
22
|
}
|
|
19
23
|
if (Array.isArray(value)) {
|
|
20
|
-
return
|
|
21
|
-
'[',
|
|
22
|
-
value.map(item => ` ${inspected(item)}`).join(',\n'),
|
|
23
|
-
']',
|
|
24
|
-
].join('\n');
|
|
24
|
+
return stringifiedArray(value, inline);
|
|
25
25
|
}
|
|
26
26
|
if (isAPromise(value)) {
|
|
27
|
-
return
|
|
27
|
+
return markAs('Promise', true);
|
|
28
28
|
}
|
|
29
29
|
if (Question_1.Question.isAQuestion(value)) {
|
|
30
|
-
return value.toString();
|
|
30
|
+
return markAs(value.toString(), markQuestions);
|
|
31
31
|
}
|
|
32
32
|
if (isADate(value)) {
|
|
33
33
|
return value.toISOString();
|
|
@@ -38,15 +38,41 @@ function inspected(value) {
|
|
|
38
38
|
if (isInspectable(value)) {
|
|
39
39
|
return value.inspect();
|
|
40
40
|
}
|
|
41
|
-
if (
|
|
42
|
-
return
|
|
41
|
+
if (isAFunction(value)) {
|
|
42
|
+
return hasName(value)
|
|
43
|
+
? value.name
|
|
44
|
+
: markAs(`Function`, true);
|
|
43
45
|
}
|
|
44
46
|
if (!hasCustomInspectionFunction(value) && isPlainObject(value) && isSerialisableAsJSON(value)) {
|
|
45
|
-
return
|
|
47
|
+
return stringifiedToJson(value, inline);
|
|
46
48
|
}
|
|
47
|
-
return (0, util_1.inspect)(value, { breakLength: Number.POSITIVE_INFINITY, compact:
|
|
49
|
+
return (0, util_1.inspect)(value, { breakLength: Number.POSITIVE_INFINITY, compact: inline ? 3 : false, sorted: false });
|
|
48
50
|
}
|
|
49
51
|
exports.inspected = inspected;
|
|
52
|
+
function stringifiedToJson(value, inline) {
|
|
53
|
+
const indentation = inline ? 0 : 4;
|
|
54
|
+
return JSON.stringify(value, undefined, indentation);
|
|
55
|
+
}
|
|
56
|
+
function stringifiedArray(value, inline) {
|
|
57
|
+
const indentation = inline ? '' : ' ';
|
|
58
|
+
const separator = inline ? ' ' : '\n';
|
|
59
|
+
const inspectedItem = (item, index) => [
|
|
60
|
+
indentation,
|
|
61
|
+
inspected(item, { inline, markQuestions: true }),
|
|
62
|
+
index < value.length - 1 ? ',' : ''
|
|
63
|
+
].join('');
|
|
64
|
+
return [
|
|
65
|
+
'[',
|
|
66
|
+
...value.map(inspectedItem),
|
|
67
|
+
']',
|
|
68
|
+
].join(separator);
|
|
69
|
+
}
|
|
70
|
+
function markAs(value, markValue) {
|
|
71
|
+
const [left, right] = markValue && !value.startsWith('<<')
|
|
72
|
+
? ['<<', '>>']
|
|
73
|
+
: ['', ''];
|
|
74
|
+
return [left, value, right].join('');
|
|
75
|
+
}
|
|
50
76
|
/**
|
|
51
77
|
* @desc
|
|
52
78
|
* Checks if the value is defined
|
|
@@ -98,7 +124,8 @@ function isADate(v) {
|
|
|
98
124
|
* @param {Answerable<any>} v
|
|
99
125
|
*/
|
|
100
126
|
function isAPromise(v) {
|
|
101
|
-
return
|
|
127
|
+
return typeof v === 'object'
|
|
128
|
+
&& 'then' in v;
|
|
102
129
|
}
|
|
103
130
|
/**
|
|
104
131
|
* @desc
|
|
@@ -107,8 +134,18 @@ function isAPromise(v) {
|
|
|
107
134
|
* @private
|
|
108
135
|
* @param {Answerable<any>} v
|
|
109
136
|
*/
|
|
110
|
-
function
|
|
111
|
-
return Object.prototype.toString.call(v) === '[object Function]'
|
|
137
|
+
function isAFunction(v) {
|
|
138
|
+
return Object.prototype.toString.call(v) === '[object Function]';
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* @desc
|
|
142
|
+
* Checks if the value is has a property called 'name' with a non-empty value.
|
|
143
|
+
*
|
|
144
|
+
* @private
|
|
145
|
+
* @param {Answerable<any>} v
|
|
146
|
+
*/
|
|
147
|
+
function hasName(v) {
|
|
148
|
+
return typeof v.name === 'string' && v.name !== '';
|
|
112
149
|
}
|
|
113
150
|
/**
|
|
114
151
|
* @desc
|
package/lib/io/inspected.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspected.js","sourceRoot":"","sources":["../../src/io/inspected.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAG/B,qDAAkD;
|
|
1
|
+
{"version":3,"file":"inspected.js","sourceRoot":"","sources":["../../src/io/inspected.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAG/B,qDAAkD;AAOlD;;;;;;;;;;;GAWG;AACH,SAAgB,SAAS,CAAC,KAAsB,EAAE,MAAwB;IAEtE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,CAAC;IAErF,IAAI,CAAE,SAAS,CAAC,KAAK,CAAC,EAAE;QACpB,OAAO,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC;KACzB;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACtB,OAAO,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;KAC1C;IAED,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,MAAM,CAAC,SAAS,E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AAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC;AACtF,CAAC"}
|
package/lib/model/Timestamp.d.ts
CHANGED
|
@@ -3,12 +3,14 @@ import { Duration } from './Duration';
|
|
|
3
3
|
export declare class Timestamp extends TinyType {
|
|
4
4
|
readonly value: Date;
|
|
5
5
|
static fromJSON(v: string): Timestamp;
|
|
6
|
-
static
|
|
6
|
+
static fromTimestampInSeconds(v: number): Timestamp;
|
|
7
|
+
static fromTimestampInMilliseconds(v: number): Timestamp;
|
|
7
8
|
constructor(value?: Date);
|
|
8
9
|
diff(another: Timestamp): Duration;
|
|
9
10
|
plus(duration: Duration): Timestamp;
|
|
10
11
|
less(duration: Duration): Timestamp;
|
|
11
|
-
|
|
12
|
+
toMilliseconds(): number;
|
|
13
|
+
toSeconds(): number;
|
|
12
14
|
toJSON(): string;
|
|
13
15
|
toString(): string;
|
|
14
16
|
}
|
package/lib/model/Timestamp.js
CHANGED
|
@@ -13,7 +13,10 @@ class Timestamp extends tiny_types_1.TinyType {
|
|
|
13
13
|
static fromJSON(v) {
|
|
14
14
|
return new Timestamp(new Date((0, tiny_types_1.ensure)(Timestamp.name, v, isSerialisedISO8601Date())));
|
|
15
15
|
}
|
|
16
|
-
static
|
|
16
|
+
static fromTimestampInSeconds(v) {
|
|
17
|
+
return Timestamp.fromTimestampInMilliseconds(v * 1000);
|
|
18
|
+
}
|
|
19
|
+
static fromTimestampInMilliseconds(v) {
|
|
17
20
|
return new Timestamp(moment(v).toDate());
|
|
18
21
|
}
|
|
19
22
|
diff(another) {
|
|
@@ -25,9 +28,12 @@ class Timestamp extends tiny_types_1.TinyType {
|
|
|
25
28
|
less(duration) {
|
|
26
29
|
return new Timestamp(moment(this.value).subtract(duration.inMilliseconds(), 'ms').toDate());
|
|
27
30
|
}
|
|
28
|
-
|
|
31
|
+
toMilliseconds() {
|
|
29
32
|
return moment(this.value).valueOf();
|
|
30
33
|
}
|
|
34
|
+
toSeconds() {
|
|
35
|
+
return moment(this.value).unix();
|
|
36
|
+
}
|
|
31
37
|
toJSON() {
|
|
32
38
|
return this.value.toJSON();
|
|
33
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Timestamp.js","sourceRoot":"","sources":["../../src/model/Timestamp.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,2CAAkF;AAElF,yCAAsC;AAEtC,MAAa,SAAU,SAAQ,qBAAQ;
|
|
1
|
+
{"version":3,"file":"Timestamp.js","sourceRoot":"","sources":["../../src/model/Timestamp.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,2CAAkF;AAElF,yCAAsC;AAEtC,MAAa,SAAU,SAAQ,qBAAQ;IAanC,YAA4B,QAAc,IAAI,IAAI,EAAE;QAChD,KAAK,EAAE,CAAC;QADgB,UAAK,GAAL,KAAK,CAAmB;QAEhD,IAAA,mBAAM,EAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,IAAA,sBAAS,GAAE,EAAE,IAAA,yBAAY,EAAC,IAAI,CAAC,CAAC,CAAC;IACnE,CAAC;IAfD,MAAM,CAAC,QAAQ,CAAC,CAAS;QACrB,OAAO,IAAI,SAAS,CAAC,IAAI,IAAI,CAAC,IAAA,mBAAM,EAAC,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC,CAAC;IACzF,CAAC;IAED,MAAM,CAAC,sBAAsB,CAAC,CAAS;QACnC,OAAO,SAAS,CAAC,2BAA2B,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,CAAS;QACxC,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;IAOD,IAAI,CAAC,OAAkB;QACnB,OAAO,IAAI,mBAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,IAAI,CAAC,QAAkB;QACnB,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,IAAI,CAAC,QAAkB;QACnB,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAChG,CAAC;IAED,cAAc;QACV,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IAED,SAAS;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,CAAC;IAED,MAAM;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;CACJ;AA7CD,8BA6CC;AAED,SAAS,uBAAuB;IAC5B,OAAO,sBAAS,CAAC,EAAE,CAAC,+BAA+B,EAAE,CAAC,KAAa,EAAE,EAAE,CACnE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Answerable } from './Answerable';
|
|
2
|
+
/**
|
|
3
|
+
* @desc
|
|
4
|
+
* `Optional` is a container object, which holds a value that may or may not be "present",
|
|
5
|
+
*
|
|
6
|
+
* The meaning of being "present" depends on the context and typically means a value that:
|
|
7
|
+
* - is other than `null` or `undefined`
|
|
8
|
+
* - is retrievable, so retrieving it doesn't throw any errors
|
|
9
|
+
*
|
|
10
|
+
* Additionally, `Optional` can also have a context-specific meaning. For example, `Optional#isPresent()`:
|
|
11
|
+
* - in the context of a `PageElement` means that the element exists in the DOM.
|
|
12
|
+
* - in the context of a `ModalWindow` means that the modal window is open.
|
|
13
|
+
* - in the case of a REST API response, `LastResponse.body().books[0].author.name.isPresent()`
|
|
14
|
+
* will inform us if a given entry exists (so `books[0].author.name`),
|
|
15
|
+
* and if all the links of the property chain leading to the entry of interest exist too
|
|
16
|
+
* (so `books` is present, and so is `books[0]`, `books[0].author`, `books[0].author.name`).
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export interface Optional {
|
|
21
|
+
/**
|
|
22
|
+
* @desc
|
|
23
|
+
* Returns an {@link Answerable} that resolves to `true` when the optional value
|
|
24
|
+
* is present, `false` otherwise.
|
|
25
|
+
*
|
|
26
|
+
* @returns {Answerable<boolean>}
|
|
27
|
+
*/
|
|
28
|
+
isPresent(): Answerable<boolean>;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Optional.js","sourceRoot":"","sources":["../../src/screenplay/Optional.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Mappable } from '../io/collections';
|
|
2
1
|
import { AnswersQuestions, UsesAbilities } from './actor';
|
|
3
|
-
import {
|
|
2
|
+
import { Answerable } from './Answerable';
|
|
3
|
+
import { Interaction } from './Interaction';
|
|
4
|
+
import { Optional } from './Optional';
|
|
4
5
|
/**
|
|
5
6
|
* @desc
|
|
6
7
|
* Enables the {@link Actor} to query the system under test.
|
|
@@ -51,14 +52,6 @@ import { AnswerMappingFunction } from './questions/mappings';
|
|
|
51
52
|
* @abstract
|
|
52
53
|
*/
|
|
53
54
|
export declare abstract class Question<T> {
|
|
54
|
-
protected subject: string;
|
|
55
|
-
/**
|
|
56
|
-
* @param {string} subject
|
|
57
|
-
* The subject of this question
|
|
58
|
-
*
|
|
59
|
-
* @protected
|
|
60
|
-
*/
|
|
61
|
-
protected constructor(subject: string);
|
|
62
55
|
/**
|
|
63
56
|
* @desc
|
|
64
57
|
* Factory method that simplifies the process of defining custom questions.
|
|
@@ -74,7 +67,7 @@ export declare abstract class Question<T> {
|
|
|
74
67
|
*
|
|
75
68
|
* @returns {Question<R>}
|
|
76
69
|
*/
|
|
77
|
-
static about<R>(description: string, body: (actor: AnswersQuestions & UsesAbilities) => R):
|
|
70
|
+
static about<R>(description: string, body: (actor: AnswersQuestions & UsesAbilities) => Promise<R> | R): QuestionAdapter<Awaited<R>>;
|
|
78
71
|
/**
|
|
79
72
|
* @desc
|
|
80
73
|
* Checks if the value is a {@link Question}.
|
|
@@ -87,13 +80,14 @@ export declare abstract class Question<T> {
|
|
|
87
80
|
* @returns {boolean}
|
|
88
81
|
*/
|
|
89
82
|
static isAQuestion<T>(maybeQuestion: unknown): maybeQuestion is Question<T>;
|
|
83
|
+
protected static createAdapter<AT>(statement: Question<AT>): QuestionAdapter<Awaited<AT>>;
|
|
90
84
|
/**
|
|
91
85
|
* @desc
|
|
92
86
|
* Describes the subject of this {@link Question}.
|
|
93
87
|
*
|
|
94
88
|
* @returns {string}
|
|
95
89
|
*/
|
|
96
|
-
toString(): string;
|
|
90
|
+
abstract toString(): string;
|
|
97
91
|
/**
|
|
98
92
|
* @desc
|
|
99
93
|
* Changes the description of this question's subject.
|
|
@@ -101,79 +95,44 @@ export declare abstract class Question<T> {
|
|
|
101
95
|
* @param {string} subject
|
|
102
96
|
* @returns {Question<T>}
|
|
103
97
|
*/
|
|
104
|
-
describedAs(subject: string): this;
|
|
105
|
-
/**
|
|
106
|
-
* @desc
|
|
107
|
-
* Creates a new {@link Question}, which value is a result of applying the `mapping`
|
|
108
|
-
* function to the value of this {@link Question}.
|
|
109
|
-
*
|
|
110
|
-
* @example <caption>Mapping a Question<Promise<string>> to Question<Promise<number>></caption>
|
|
111
|
-
* import { Question, replace, toNumber } from '@serenity-js/core';
|
|
112
|
-
*
|
|
113
|
-
* Question.about('the price of some item', actor => '$3.99')
|
|
114
|
-
* .map(replace('$', ''))
|
|
115
|
-
* .map(toNumber)
|
|
116
|
-
*
|
|
117
|
-
* // => Question<Promise<number>>
|
|
118
|
-
* // 3.99
|
|
119
|
-
*
|
|
120
|
-
* @example <caption>Mapping all items of Question<string[]> to Question<Promise<number>></caption>
|
|
121
|
-
* import { Question, trim } from '@serenity-js/core';
|
|
122
|
-
*
|
|
123
|
-
* Question.about('things to do', actor => [ ' walk the dog ', ' read a book ' ])
|
|
124
|
-
* .map(trim())
|
|
125
|
-
*
|
|
126
|
-
* // => Question<Promise<string[]>>
|
|
127
|
-
* // [ 'walk the dog', 'read a book' ]
|
|
128
|
-
*
|
|
129
|
-
* @example <caption>Using a custom mapping function</caption>
|
|
130
|
-
* import { Question } from '@serenity-js/core';
|
|
131
|
-
*
|
|
132
|
-
* Question.about('normalised percentages', actor => [ 0.1, 0.3, 0.6 ])
|
|
133
|
-
* .map((actor: AnswersQuestions) => (value: number) => value * 100)
|
|
134
|
-
*
|
|
135
|
-
* // => Question<Promise<number[]>>
|
|
136
|
-
* // [ 10, 30, 60 ]
|
|
137
|
-
*
|
|
138
|
-
* @example <caption>Extracting values from LastResponse.body()</caption>
|
|
139
|
-
* import { Question } from '@serenity-js/core';
|
|
140
|
-
* import { LastResponse } from '@serenity-js/rest';
|
|
141
|
-
*
|
|
142
|
-
* interface UserDetails {
|
|
143
|
-
* id: number;
|
|
144
|
-
* name: string;
|
|
145
|
-
* }
|
|
146
|
-
*
|
|
147
|
-
* LastResponse.body<UserDetails>().map(actor => details => details.id)
|
|
148
|
-
*
|
|
149
|
-
* // => Question<number>
|
|
150
|
-
*
|
|
151
|
-
* @param {function(value: A, index?: number): Promise<O> | O} mapping
|
|
152
|
-
* A mapping function that receives a value of type `<A>`, which is either:
|
|
153
|
-
* - an answer to the original question, if the question is defined as `Question<Promise<A>>` or `Question<A>`
|
|
154
|
-
* - or, if the question is defined as `Question<Promise<Mappable<A>>`, `Question<Mappable<A>>` - each item of the {@link Mappable} collection,
|
|
155
|
-
*
|
|
156
|
-
* @returns {Question<Promise<Mapped>>}
|
|
157
|
-
* A new Question which value is a result of applying the `mapping` function
|
|
158
|
-
* to the value of the current question, so that:
|
|
159
|
-
* - if the answer to the current question is a `Mappable<A>`, the result becomes `Question<Promise<O[]>>`
|
|
160
|
-
* - if the answer is a value `<A>` or `Promise<A>`, the result becomes `Question<Promise<O>>`
|
|
161
|
-
*
|
|
162
|
-
* @see {@link AnswerMappingFunction}
|
|
163
|
-
* @see {@link Mappable}
|
|
164
|
-
*/
|
|
165
|
-
map<O>(mapping: AnswerMappingFunction<AnswerOrItemOfMappableCollection<T>, O>): Question<Promise<Mapped<T, O>>>;
|
|
98
|
+
abstract describedAs(subject: string): this;
|
|
166
99
|
/**
|
|
167
100
|
* @abstract
|
|
168
101
|
*/
|
|
169
102
|
abstract answeredBy(actor: AnswersQuestions & UsesAbilities): T;
|
|
103
|
+
as<O>(mapping: (answer: Awaited<T>) => Promise<O> | O): QuestionAdapter<O>;
|
|
104
|
+
}
|
|
105
|
+
declare global {
|
|
106
|
+
interface ProxyConstructor {
|
|
107
|
+
new <Source_Type extends object, Target_Type extends object>(target: Source_Type, handler: ProxyHandler<Source_Type>): Target_Type;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export declare type ProxiedAnswer<Original_Type> = {
|
|
111
|
+
[Field in keyof Omit<Original_Type, keyof QuestionStatement<Original_Type>>]: Original_Type[Field] extends (...args: infer OriginalParameters) => infer OriginalMethodResult ? (...args: {
|
|
112
|
+
[P in keyof OriginalParameters]: Answerable<OriginalParameters[P]>;
|
|
113
|
+
}) => {
|
|
114
|
+
isPresent(): Question<Promise<boolean>>;
|
|
115
|
+
} & QuestionAdapter<Awaited<OriginalMethodResult>> : {
|
|
116
|
+
isPresent(): Question<Promise<boolean>>;
|
|
117
|
+
} & QuestionAdapter<Awaited<Original_Type[Field]>>;
|
|
118
|
+
};
|
|
119
|
+
export declare type QuestionAdapter<Original_Type> = Question<Promise<Original_Type>> & Interaction & Optional & ProxiedAnswer<Original_Type>;
|
|
120
|
+
declare class QuestionStatement<Answer_Type> extends Interaction implements Question<Promise<Answer_Type>>, Optional {
|
|
121
|
+
private subject;
|
|
122
|
+
private readonly body;
|
|
123
|
+
constructor(subject: string, body: (actor: AnswersQuestions & UsesAbilities, ...Parameters: any[]) => Promise<Answer_Type> | Answer_Type);
|
|
124
|
+
/**
|
|
125
|
+
* @desc
|
|
126
|
+
* Returns a Question that resolves to `true` if resolving the {@link QuestionStatement}
|
|
127
|
+
* returns a value other than `null` or `undefined` and doesn't throw errors.
|
|
128
|
+
*
|
|
129
|
+
* @returns {Question<Promise<boolean>>}
|
|
130
|
+
*/
|
|
131
|
+
isPresent(): Question<Promise<boolean>>;
|
|
132
|
+
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<Answer_Type>;
|
|
133
|
+
performAs(actor: UsesAbilities & AnswersQuestions): Promise<void>;
|
|
134
|
+
describedAs(subject: string): this;
|
|
135
|
+
toString(): string;
|
|
136
|
+
as<O>(mapping: (answer: Awaited<Answer_Type>) => (Promise<O> | O)): QuestionAdapter<O>;
|
|
170
137
|
}
|
|
171
|
-
/**
|
|
172
|
-
* @package
|
|
173
|
-
*/
|
|
174
|
-
declare type AnswerOrItemOfMappableCollection<V> = V extends PromiseLike<infer PromisedValue> ? PromisedValue extends Mappable<infer Item> ? Item : PromisedValue : V extends Mappable<infer Item> ? Item : V;
|
|
175
|
-
/**
|
|
176
|
-
* @package
|
|
177
|
-
*/
|
|
178
|
-
declare type Mapped<T, O> = T extends PromiseLike<infer PromisedValue> ? PromisedValue extends Mappable<infer Item> ? O[] : O : T extends Mappable<infer Item> ? O[] : O;
|
|
179
138
|
export {};
|