@serenity-js/core 2.32.3 → 3.0.0-rc.1
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 +61 -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/collections/index.d.ts +0 -1
- package/lib/io/collections/index.js +0 -1
- package/lib/io/collections/index.js.map +1 -1
- 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 +1 -0
- package/lib/io/index.js +1 -0
- 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/screenplay/{questions/proxies/PropertyPathKey.js → 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 +112 -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 +10 -0
- package/lib/screenplay/questions/List.js +16 -1
- 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/screenplay/questions/lists/ArrayListAdapter.js +20 -5
- package/lib/screenplay/questions/lists/ArrayListAdapter.js.map +1 -1
- package/package.json +9 -9
- package/src/index.ts +2 -1
- package/src/io/ErrorSerialiser.ts +5 -1
- package/src/io/collections/index.ts +0 -1
- package/src/io/format.ts +46 -0
- package/src/io/formatted.ts +7 -15
- package/src/io/index.ts +1 -0
- 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 +142 -0
- package/src/screenplay/model/index.ts +2 -0
- package/src/screenplay/questions/Expectation.ts +20 -1
- package/src/screenplay/questions/List.ts +19 -1
- package/src/screenplay/questions/Note.ts +21 -1
- package/src/screenplay/questions/index.ts +0 -3
- package/src/screenplay/questions/lists/ArrayListAdapter.ts +21 -2
- 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/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/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.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/mappable.ts +0 -60
- package/src/screenplay/questions/Property.ts +0 -98
- package/src/screenplay/questions/Transform.ts +0 -51
- 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,6 +1,5 @@
|
|
|
1
|
-
import { Mappable } from '../io/collections';
|
|
2
1
|
import { AnswersQuestions, UsesAbilities } from './actor';
|
|
3
|
-
import {
|
|
2
|
+
import { Adapter } from './model';
|
|
4
3
|
/**
|
|
5
4
|
* @desc
|
|
6
5
|
* Enables the {@link Actor} to query the system under test.
|
|
@@ -51,14 +50,6 @@ import { AnswerMappingFunction } from './questions/mappings';
|
|
|
51
50
|
* @abstract
|
|
52
51
|
*/
|
|
53
52
|
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
53
|
/**
|
|
63
54
|
* @desc
|
|
64
55
|
* Factory method that simplifies the process of defining custom questions.
|
|
@@ -74,7 +65,7 @@ export declare abstract class Question<T> {
|
|
|
74
65
|
*
|
|
75
66
|
* @returns {Question<R>}
|
|
76
67
|
*/
|
|
77
|
-
static about<R>(description: string, body: (actor: AnswersQuestions & UsesAbilities) => R): Question<R
|
|
68
|
+
static about<R>(description: string, body: (actor: AnswersQuestions & UsesAbilities) => R): Question<R> & Adapter<Awaited<R>>;
|
|
78
69
|
/**
|
|
79
70
|
* @desc
|
|
80
71
|
* Checks if the value is a {@link Question}.
|
|
@@ -93,7 +84,7 @@ export declare abstract class Question<T> {
|
|
|
93
84
|
*
|
|
94
85
|
* @returns {string}
|
|
95
86
|
*/
|
|
96
|
-
toString(): string;
|
|
87
|
+
abstract toString(): string;
|
|
97
88
|
/**
|
|
98
89
|
* @desc
|
|
99
90
|
* Changes the description of this question's subject.
|
|
@@ -101,79 +92,11 @@ export declare abstract class Question<T> {
|
|
|
101
92
|
* @param {string} subject
|
|
102
93
|
* @returns {Question<T>}
|
|
103
94
|
*/
|
|
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>>>;
|
|
95
|
+
abstract describedAs(subject: string): this;
|
|
166
96
|
/**
|
|
167
97
|
* @abstract
|
|
98
|
+
* // todo check why api docs are not getting generated for this methods
|
|
168
99
|
*/
|
|
169
100
|
abstract answeredBy(actor: AnswersQuestions & UsesAbilities): T;
|
|
101
|
+
as<O>(mapping: (answer: Awaited<T>) => Promise<O> | O): Question<Promise<O>>;
|
|
170
102
|
}
|
|
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
|
-
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Question = void 0;
|
|
4
|
-
const
|
|
4
|
+
const inspected_1 = require("../io/inspected");
|
|
5
|
+
const model_1 = require("./model");
|
|
5
6
|
/**
|
|
6
7
|
* @desc
|
|
7
8
|
* Enables the {@link Actor} to query the system under test.
|
|
@@ -52,15 +53,6 @@ const collections_1 = require("../io/collections");
|
|
|
52
53
|
* @abstract
|
|
53
54
|
*/
|
|
54
55
|
class Question {
|
|
55
|
-
/**
|
|
56
|
-
* @param {string} subject
|
|
57
|
-
* The subject of this question
|
|
58
|
-
*
|
|
59
|
-
* @protected
|
|
60
|
-
*/
|
|
61
|
-
constructor(subject) {
|
|
62
|
-
this.subject = subject;
|
|
63
|
-
}
|
|
64
56
|
/**
|
|
65
57
|
* @desc
|
|
66
58
|
* Factory method that simplifies the process of defining custom questions.
|
|
@@ -77,7 +69,7 @@ class Question {
|
|
|
77
69
|
* @returns {Question<R>}
|
|
78
70
|
*/
|
|
79
71
|
static about(description, body) {
|
|
80
|
-
return new AnonymousQuestion(description, body);
|
|
72
|
+
return (0, model_1.createAdapter)(new AnonymousQuestion(description, body));
|
|
81
73
|
}
|
|
82
74
|
/**
|
|
83
75
|
* @desc
|
|
@@ -93,90 +85,11 @@ class Question {
|
|
|
93
85
|
static isAQuestion(maybeQuestion) {
|
|
94
86
|
return !!maybeQuestion && !!maybeQuestion.answeredBy;
|
|
95
87
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*/
|
|
102
|
-
toString() {
|
|
103
|
-
return this.subject;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* @desc
|
|
107
|
-
* Changes the description of this question's subject.
|
|
108
|
-
*
|
|
109
|
-
* @param {string} subject
|
|
110
|
-
* @returns {Question<T>}
|
|
111
|
-
*/
|
|
112
|
-
describedAs(subject) {
|
|
113
|
-
this.subject = subject;
|
|
114
|
-
return this;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* @desc
|
|
118
|
-
* Creates a new {@link Question}, which value is a result of applying the `mapping`
|
|
119
|
-
* function to the value of this {@link Question}.
|
|
120
|
-
*
|
|
121
|
-
* @example <caption>Mapping a Question<Promise<string>> to Question<Promise<number>></caption>
|
|
122
|
-
* import { Question, replace, toNumber } from '@serenity-js/core';
|
|
123
|
-
*
|
|
124
|
-
* Question.about('the price of some item', actor => '$3.99')
|
|
125
|
-
* .map(replace('$', ''))
|
|
126
|
-
* .map(toNumber)
|
|
127
|
-
*
|
|
128
|
-
* // => Question<Promise<number>>
|
|
129
|
-
* // 3.99
|
|
130
|
-
*
|
|
131
|
-
* @example <caption>Mapping all items of Question<string[]> to Question<Promise<number>></caption>
|
|
132
|
-
* import { Question, trim } from '@serenity-js/core';
|
|
133
|
-
*
|
|
134
|
-
* Question.about('things to do', actor => [ ' walk the dog ', ' read a book ' ])
|
|
135
|
-
* .map(trim())
|
|
136
|
-
*
|
|
137
|
-
* // => Question<Promise<string[]>>
|
|
138
|
-
* // [ 'walk the dog', 'read a book' ]
|
|
139
|
-
*
|
|
140
|
-
* @example <caption>Using a custom mapping function</caption>
|
|
141
|
-
* import { Question } from '@serenity-js/core';
|
|
142
|
-
*
|
|
143
|
-
* Question.about('normalised percentages', actor => [ 0.1, 0.3, 0.6 ])
|
|
144
|
-
* .map((actor: AnswersQuestions) => (value: number) => value * 100)
|
|
145
|
-
*
|
|
146
|
-
* // => Question<Promise<number[]>>
|
|
147
|
-
* // [ 10, 30, 60 ]
|
|
148
|
-
*
|
|
149
|
-
* @example <caption>Extracting values from LastResponse.body()</caption>
|
|
150
|
-
* import { Question } from '@serenity-js/core';
|
|
151
|
-
* import { LastResponse } from '@serenity-js/rest';
|
|
152
|
-
*
|
|
153
|
-
* interface UserDetails {
|
|
154
|
-
* id: number;
|
|
155
|
-
* name: string;
|
|
156
|
-
* }
|
|
157
|
-
*
|
|
158
|
-
* LastResponse.body<UserDetails>().map(actor => details => details.id)
|
|
159
|
-
*
|
|
160
|
-
* // => Question<number>
|
|
161
|
-
*
|
|
162
|
-
* @param {function(value: A, index?: number): Promise<O> | O} mapping
|
|
163
|
-
* A mapping function that receives a value of type `<A>`, which is either:
|
|
164
|
-
* - an answer to the original question, if the question is defined as `Question<Promise<A>>` or `Question<A>`
|
|
165
|
-
* - or, if the question is defined as `Question<Promise<Mappable<A>>`, `Question<Mappable<A>>` - each item of the {@link Mappable} collection,
|
|
166
|
-
*
|
|
167
|
-
* @returns {Question<Promise<Mapped>>}
|
|
168
|
-
* A new Question which value is a result of applying the `mapping` function
|
|
169
|
-
* to the value of the current question, so that:
|
|
170
|
-
* - if the answer to the current question is a `Mappable<A>`, the result becomes `Question<Promise<O[]>>`
|
|
171
|
-
* - if the answer is a value `<A>` or `Promise<A>`, the result becomes `Question<Promise<O>>`
|
|
172
|
-
*
|
|
173
|
-
* @see {@link AnswerMappingFunction}
|
|
174
|
-
* @see {@link Mappable}
|
|
175
|
-
*/
|
|
176
|
-
map(mapping) {
|
|
177
|
-
return Question.about(this.subject, actor => actor.answer(this).then(value => ((0, collections_1.isMappable)(value)
|
|
178
|
-
? Promise.all((value).map(mapping(actor)))
|
|
179
|
-
: mapping(actor)(value))));
|
|
88
|
+
as(mapping) {
|
|
89
|
+
return Question.about(`${this.toString()} as ${(0, inspected_1.inspected)(mapping, { inline: true })}`, async (actor) => {
|
|
90
|
+
const answer = (await actor.answer(this));
|
|
91
|
+
return mapping(answer);
|
|
92
|
+
});
|
|
180
93
|
}
|
|
181
94
|
}
|
|
182
95
|
exports.Question = Question;
|
|
@@ -184,9 +97,9 @@ exports.Question = Question;
|
|
|
184
97
|
* @package
|
|
185
98
|
*/
|
|
186
99
|
class AnonymousQuestion extends Question {
|
|
187
|
-
constructor(
|
|
188
|
-
super(
|
|
189
|
-
this.
|
|
100
|
+
constructor(subject, body) {
|
|
101
|
+
super();
|
|
102
|
+
this.subject = subject;
|
|
190
103
|
this.body = body;
|
|
191
104
|
}
|
|
192
105
|
answeredBy(actor) {
|
|
@@ -203,5 +116,8 @@ class AnonymousQuestion extends Question {
|
|
|
203
116
|
this.subject = subject;
|
|
204
117
|
return this;
|
|
205
118
|
}
|
|
119
|
+
toString() {
|
|
120
|
+
return this.subject;
|
|
121
|
+
}
|
|
206
122
|
}
|
|
207
123
|
//# sourceMappingURL=Question.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Question.js","sourceRoot":"","sources":["../../src/screenplay/Question.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Question.js","sourceRoot":"","sources":["../../src/screenplay/Question.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAE5C,mCAAiD;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAsB,QAAQ;IAE1B;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,KAAK,CAAI,WAAmB,EAAE,IAAoD;QACrF,OAAO,IAAA,qBAAa,EAAI,IAAI,iBAAiB,CAAI,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,WAAW,CAAI,aAAsB;QACxC,OAAO,CAAC,CAAE,aAAa,IAAI,CAAC,CAAG,aAAqB,CAAC,UAAU,CAAC;IACpE,CAAC;IAyBM,EAAE,CAAI,OAA+C;QACxD,OAAO,QAAQ,CAAC,KAAK,CAAa,GAAI,IAAI,CAAC,QAAQ,EAAG,OAAQ,IAAA,qBAAS,EAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAE,EAAE,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YACjH,MAAM,MAAM,GAAG,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAe,CAAC;YACxD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAjED,4BAiEC;AAED;;GAEG;AACH,MAAM,iBAAqB,SAAQ,QAAW;IAC1C,YAAoB,OAAe,EAAU,IAAoD;QAC7F,KAAK,EAAE,CAAC;QADQ,YAAO,GAAP,OAAO,CAAQ;QAAU,SAAI,GAAJ,IAAI,CAAgD;IAEjG,CAAC;IAED,UAAU,CAAC,KAAuC;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,OAAe;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ"}
|
|
@@ -89,10 +89,10 @@ class Actor {
|
|
|
89
89
|
*/
|
|
90
90
|
answer(answerable) {
|
|
91
91
|
function isAPromise(v) {
|
|
92
|
-
return
|
|
92
|
+
return Object.prototype.hasOwnProperty.call(v, 'then');
|
|
93
93
|
}
|
|
94
94
|
function isDefined(v) {
|
|
95
|
-
return !(
|
|
95
|
+
return !(v === undefined || v === null);
|
|
96
96
|
}
|
|
97
97
|
if (isDefined(answerable) && isAPromise(answerable)) {
|
|
98
98
|
return answerable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actor.js","sourceRoot":"","sources":["../../../src/screenplay/actor/Actor.ts"],"names":[],"mappings":";;;AAAA,yCAAwE;AACxE,yCAAgE;AAChE,uCAA6C;AAG7C,8CAAgD;AAEhD,0CAAuC;AAOvC,MAAa,KAAK;IAOd,+CAA+C;IAC/C,gDAAgD;IAChD,oEAAoE;IAEpE,YACoB,IAAY,EACX,KAAY,EACZ,YAAgD,IAAI,GAAG,EAAiC;QAFzF,SAAI,GAAJ,IAAI,CAAQ;QACX,UAAK,GAAL,KAAK,CAAO;QACZ,cAAS,GAAT,SAAS,CAA+E;IAE7G,CAAC;IAED;;;;;;;;;OASG;IACH,SAAS,CAAoB,WAA2B;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAE9C,IAAI,CAAE,KAAK,EAAE;YACT,M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E;YAClD,IAAI,OAAO,YAAY,WAAW,EAAE;gBAChC,OAAO,OAAY,CAAC;aACvB;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;;;;;;;;OASG;IACK,QAAQ,CAAC,SAAwB;QACrC,OAAO,OAAO,SAAS,KAAK,QAAQ;YAChC,CAAC,CAAC,IAAI,YAAI,CAAC,SAAS,CAAC;YACrB,CAAC,CAAC,SAAS,CAAC;IACpB,CAAC;CACJ;AApOD,sBAoOC"}
|
|
@@ -6,7 +6,7 @@ export * from './actor';
|
|
|
6
6
|
export * from './Answerable';
|
|
7
7
|
export * from './Interaction';
|
|
8
8
|
export * from './interactions';
|
|
9
|
+
export * from './model';
|
|
9
10
|
export * from './Question';
|
|
10
11
|
export * from './questions';
|
|
11
12
|
export * from './Task';
|
|
12
|
-
export * from './tasks';
|
package/lib/screenplay/index.js
CHANGED
|
@@ -18,8 +18,8 @@ __exportStar(require("./actor"), exports);
|
|
|
18
18
|
__exportStar(require("./Answerable"), exports);
|
|
19
19
|
__exportStar(require("./Interaction"), exports);
|
|
20
20
|
__exportStar(require("./interactions"), exports);
|
|
21
|
+
__exportStar(require("./model"), exports);
|
|
21
22
|
__exportStar(require("./Question"), exports);
|
|
22
23
|
__exportStar(require("./questions"), exports);
|
|
23
24
|
__exportStar(require("./Task"), exports);
|
|
24
|
-
__exportStar(require("./tasks"), exports);
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA4B;AAC5B,4CAA0B;AAC1B,gDAA8B;AAC9B,6CAA2B;AAC3B,0CAAwB;AACxB,+CAA6B;AAC7B,gDAA8B;AAC9B,iDAA+B;AAC/B,6CAA2B;AAC3B,8CAA4B;AAC5B,yCAAuB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA4B;AAC5B,4CAA0B;AAC1B,gDAA8B;AAC9B,6CAA2B;AAC3B,0CAAwB;AACxB,+CAA6B;AAC7B,gDAA8B;AAC9B,iDAA+B;AAC/B,0CAAwB;AACxB,6CAA2B;AAC3B,8CAA4B;AAC5B,yCAAuB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Answerable } from '../Answerable';
|
|
2
|
+
import { Interaction } from '../Interaction';
|
|
3
|
+
import { Question } from '../Question';
|
|
4
|
+
export declare type Adapter<OriginalType> = {
|
|
5
|
+
[Field in keyof Omit<OriginalType, keyof Question<OriginalType>>]: OriginalType[Field] extends (...args: infer OriginalParameters) => infer OriginalMethodResult ? (...args: {
|
|
6
|
+
[P in keyof OriginalParameters]: Answerable<OriginalParameters[P]>;
|
|
7
|
+
}) => Question<Promise<Awaited<OriginalMethodResult>>> & Interaction & Adapter<Awaited<OriginalMethodResult>> : Question<Promise<Awaited<OriginalType[Field]>>> & Interaction & Adapter<Awaited<OriginalType[Field]>>;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Adapter.js","sourceRoot":"","sources":["../../../src/screenplay/model/Adapter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAdapter = void 0;
|
|
4
|
+
const errors_1 = require("../../errors");
|
|
5
|
+
const inspected_1 = require("../../io/inspected");
|
|
6
|
+
const Interaction_1 = require("../Interaction");
|
|
7
|
+
const Question_1 = require("../Question");
|
|
8
|
+
function createAdapter(question) {
|
|
9
|
+
return new Proxy(question, {
|
|
10
|
+
get(target, key, receiver) {
|
|
11
|
+
if (key === Symbol.toPrimitive) {
|
|
12
|
+
return (_hint) => {
|
|
13
|
+
return target.toString();
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (key in target) {
|
|
17
|
+
return Reflect.get(target, key, receiver);
|
|
18
|
+
}
|
|
19
|
+
if (doNotProxy(key)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const fieldDescription = (typeof key === 'number' || /^\d+$/.test(String(key)))
|
|
23
|
+
? `[${String(key)}]` // array index
|
|
24
|
+
: `.${String(key)}`; // field/method name
|
|
25
|
+
// when property is invoked as a method
|
|
26
|
+
function proxy(...originalParameters) {
|
|
27
|
+
const parameterDescriptions = [
|
|
28
|
+
'(',
|
|
29
|
+
originalParameters.map(p => (0, inspected_1.inspected)(p, { inline: true, markQuestions: true })).join(', '),
|
|
30
|
+
')'
|
|
31
|
+
].join('');
|
|
32
|
+
const originalSubject = (0, inspected_1.inspected)(question, { inline: true, markQuestions: true });
|
|
33
|
+
return createAdapter(new DynamicProp(originalSubject + fieldDescription + parameterDescriptions, async (actor) => {
|
|
34
|
+
// resolve the original answer
|
|
35
|
+
const answer = await actor.answer(target);
|
|
36
|
+
if (answer === undefined) {
|
|
37
|
+
throw new errors_1.LogicError(`${(0, inspected_1.inspected)(target, { inline: true, markQuestions: true })} is undefined, can't read property '${String(key)}'`);
|
|
38
|
+
}
|
|
39
|
+
if (typeof answer[key] !== 'function') {
|
|
40
|
+
throw new errors_1.LogicError(`${(0, inspected_1.inspected)(target, { inline: true, markQuestions: true })} does not have a method called '${String(key)}'`);
|
|
41
|
+
}
|
|
42
|
+
// convert parameters from Answerable<T> => T
|
|
43
|
+
const parameters = await (Promise.all(originalParameters.map(parameter => {
|
|
44
|
+
return actor.answer(parameter);
|
|
45
|
+
})));
|
|
46
|
+
// invoke the method call on the original answer
|
|
47
|
+
return answer[key](...parameters);
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
const originalSubject = (0, inspected_1.inspected)(question, { inline: true, markQuestions: true });
|
|
51
|
+
proxy.subject = originalSubject + fieldDescription;
|
|
52
|
+
// when property is accessed as a field
|
|
53
|
+
const body = async (actor) => {
|
|
54
|
+
const answer = await actor.answer(target);
|
|
55
|
+
if (answer === undefined) {
|
|
56
|
+
throw new errors_1.LogicError(`${target} is undefined, can't read property "${String(key)}"`);
|
|
57
|
+
}
|
|
58
|
+
return answer[key];
|
|
59
|
+
};
|
|
60
|
+
proxy.answeredBy = body;
|
|
61
|
+
proxy.performAs = body;
|
|
62
|
+
proxy.toString = () => {
|
|
63
|
+
return proxy.subject;
|
|
64
|
+
};
|
|
65
|
+
proxy.describedAs = (newSubject) => {
|
|
66
|
+
proxy.subject = newSubject;
|
|
67
|
+
return proxy;
|
|
68
|
+
};
|
|
69
|
+
proxy.as = (mapping) => {
|
|
70
|
+
return Question_1.Question.about(`${proxy.subject} as ${(0, inspected_1.inspected)(mapping, { inline: true })}`, async (actor) => {
|
|
71
|
+
const answer = await actor.answer(proxy);
|
|
72
|
+
return mapping(answer);
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
return createAdapter(proxy);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
exports.createAdapter = createAdapter;
|
|
80
|
+
function doNotProxy(key) {
|
|
81
|
+
const prohibited = [
|
|
82
|
+
'then', // don't proxy Promises
|
|
83
|
+
];
|
|
84
|
+
return prohibited.includes(key);
|
|
85
|
+
}
|
|
86
|
+
class DynamicProp extends Interaction_1.Interaction {
|
|
87
|
+
constructor(subject, body) {
|
|
88
|
+
super();
|
|
89
|
+
this.subject = subject;
|
|
90
|
+
this.body = body;
|
|
91
|
+
}
|
|
92
|
+
answeredBy(actor) {
|
|
93
|
+
return this.body(actor);
|
|
94
|
+
}
|
|
95
|
+
async performAs(actor) {
|
|
96
|
+
await this.body(actor);
|
|
97
|
+
}
|
|
98
|
+
as(mapping) {
|
|
99
|
+
return createAdapter(new DynamicProp(`${this.subject} as ${(0, inspected_1.inspected)(mapping, { inline: true })}`, async (actor) => {
|
|
100
|
+
const answer = (await actor.answer(this));
|
|
101
|
+
return mapping(answer);
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
describedAs(subject) {
|
|
105
|
+
this.subject = subject;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
toString() {
|
|
109
|
+
return this.subject;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=createAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAdapter.js","sourceRoot":"","sources":["../../../src/screenplay/model/createAdapter.ts"],"names":[],"mappings":";;;AAAA,yCAA0C;AAC1C,kDAA+C;AAE/C,gDAA6C;AAC7C,0CAAuC;AAGvC,SAAgB,aAAa,CAAyC,QAAW;IAE7E,OAAO,IAAI,KAAK,CAAI,QAAQ,EAAE;QAE1B,GAAG,CAAC,MAAS,EAAE,GAA6B,EAAE,QAAa;YACvD,IAAI,GAAG,KAAK,MAAM,CAAC,WAAW,EAAE;gBAC5B,OAAO,CAAC,KAAsC,EAAE,EAAE;oBAC9C,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAC7B,CAAC,CAAA;aACJ;YAED,IAAI,GAAG,IAAI,MAAM,EAAE;gBACf,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;aAC7C;YAED,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE;gBACjB,OAAO;aACV;YAED,MAAM,gBAAgB,GAAG,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC3E,CAAC,CAAC,IAAK,MAAM,CAAC,GAAG,CAAE,GAAG,CAAE,cAAc;gBACtC,CAAC,CAAC,IAAK,MAAM,CAAC,GAAG,CAAE,EAAE,CAAC,CAAE,oBAAoB;YAEhD,uCAAuC;YACvC,SAAS,KAAK,CAAC,GAAG,kBAAkB;gBAEhC,MAAM,qBAAqB,GAAG;oBAC1B,GAAG;oBACH,kBAAkB,CAAC,GAAG,CAAC,CAAC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CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ"}
|
|
@@ -10,5 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
13
|
+
__exportStar(require("./Adapter"), exports);
|
|
14
|
+
__exportStar(require("./createAdapter"), exports);
|
|
14
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/model/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,kDAAgC"}
|
|
@@ -14,6 +14,8 @@ export declare type Predicate<A, E> = (actual: A, expected: E) => boolean;
|
|
|
14
14
|
* @extends {Question}
|
|
15
15
|
*/
|
|
16
16
|
export declare abstract class Expectation<Expected, Actual = Expected> extends Question<(actual: Actual) => Promise<ExpectationOutcome<Expected, Actual>>> {
|
|
17
|
+
protected subject: string;
|
|
18
|
+
constructor(subject: string);
|
|
17
19
|
/**
|
|
18
20
|
* @desc
|
|
19
21
|
* Used to define a simple {@link Expectation}
|
|
@@ -68,4 +70,13 @@ export declare abstract class Expectation<Expected, Actual = Expected> extends Q
|
|
|
68
70
|
soThatActual: (...expectations: Array<Expectation<any, A>>) => Expectation<any, A>;
|
|
69
71
|
};
|
|
70
72
|
abstract answeredBy(actor: AnswersQuestions): (actual: Actual) => Promise<ExpectationOutcome<Expected, Actual>>;
|
|
73
|
+
/**
|
|
74
|
+
* @desc
|
|
75
|
+
* Changes the description of this question's subject.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} subject
|
|
78
|
+
* @returns {Question<T>}
|
|
79
|
+
*/
|
|
80
|
+
describedAs(subject: string): this;
|
|
81
|
+
toString(): string;
|
|
71
82
|
}
|
|
@@ -12,6 +12,10 @@ const expectations_1 = require("./expectations");
|
|
|
12
12
|
* @extends {Question}
|
|
13
13
|
*/
|
|
14
14
|
class Expectation extends __1.Question {
|
|
15
|
+
constructor(subject) {
|
|
16
|
+
super();
|
|
17
|
+
this.subject = subject;
|
|
18
|
+
}
|
|
15
19
|
/**
|
|
16
20
|
* @desc
|
|
17
21
|
* Used to define a simple {@link Expectation}
|
|
@@ -73,6 +77,20 @@ class Expectation extends __1.Question {
|
|
|
73
77
|
},
|
|
74
78
|
};
|
|
75
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* @desc
|
|
82
|
+
* Changes the description of this question's subject.
|
|
83
|
+
*
|
|
84
|
+
* @param {string} subject
|
|
85
|
+
* @returns {Question<T>}
|
|
86
|
+
*/
|
|
87
|
+
describedAs(subject) {
|
|
88
|
+
this.subject = subject;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
toString() {
|
|
92
|
+
return this.subject;
|
|
93
|
+
}
|
|
76
94
|
}
|
|
77
95
|
exports.Expectation = Expectation;
|
|
78
96
|
/**
|
|
@@ -81,7 +99,6 @@ exports.Expectation = Expectation;
|
|
|
81
99
|
class DynamicallyGeneratedExpectation extends Expectation {
|
|
82
100
|
constructor(description, predicate, expectedValue) {
|
|
83
101
|
super(`${description} ${(0, io_1.formatted) `${expectedValue}`}`);
|
|
84
|
-
this.description = description;
|
|
85
102
|
this.predicate = predicate;
|
|
86
103
|
this.expectedValue = expectedValue;
|
|
87
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Expectation.js","sourceRoot":"","sources":["../../../src/screenplay/questions/Expectation.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AACrC,2BAA6D;AAC7D,iDAAwF;AASxF;;;;;;GAMG;AACH,MAAsB,WAClB,SAAQ,YAA2E;
|
|
1
|
+
{"version":3,"file":"Expectation.js","sourceRoot":"","sources":["../../../src/screenplay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E,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;aACtD,IAAI,CAAC,QAAQ,CAAC,EAAE;YACb,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC;gBACnC,CAAC,CAAC,IAAI,6BAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC;gBACvD,CAAC,CAAC,IAAI,gCAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,gBAAyB,SAAQ,WAAwB;IAE3D,YACI,OAAe,EACE,WAAqC;QAEtD,KAAK,CAAC,OAAO,CAAC,CAAC;QAFE,gBAAW,GAAX,WAAW,CAA0B;IAG1D,CAAC;IAED,UAAU,CAAC,KAAuB;QAE9B,OAAO,CAAC,MAAc,EAAE,EAAE,CACtB,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,YAAY,6BAAc;YAC5E,CAAC,CAAC,IAAI,6BAAc,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;YACxD,CAAC,CAAC,IAAI,gCAAiB,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACtE,CAAC;CACJ"}
|
|
@@ -55,6 +55,7 @@ import { MetaQuestion } from './MetaQuestion';
|
|
|
55
55
|
*/
|
|
56
56
|
export declare class List<List_Adapter_Type extends ListAdapter<Item_Type, Collection_Type, Item_Return_Type, Collection_Return_Type>, Item_Type, Collection_Type, Item_Return_Type = Item_Type, Collection_Return_Type = Collection_Type> extends Question<Collection_Return_Type> {
|
|
57
57
|
private readonly collection;
|
|
58
|
+
private subject;
|
|
58
59
|
/**
|
|
59
60
|
* @desc
|
|
60
61
|
* Instantiates a new {@link List} configured to support standard {@link Array}.
|
|
@@ -192,5 +193,14 @@ export declare class List<List_Adapter_Type extends ListAdapter<Item_Type, Colle
|
|
|
192
193
|
* @see {@link UsesAbilities}
|
|
193
194
|
*/
|
|
194
195
|
answeredBy(actor: AnswersQuestions & UsesAbilities): Collection_Return_Type;
|
|
196
|
+
/**
|
|
197
|
+
* @desc
|
|
198
|
+
* Changes the description of this question's subject.
|
|
199
|
+
*
|
|
200
|
+
* @param {string} subject
|
|
201
|
+
* @returns {Question<T>}
|
|
202
|
+
*/
|
|
203
|
+
describedAs(subject: string): this;
|
|
204
|
+
toString(): string;
|
|
195
205
|
private static ordinalSuffixOf;
|
|
196
206
|
}
|
|
@@ -58,8 +58,9 @@ class List extends Question_1.Question {
|
|
|
58
58
|
* @param {List_Adapter_Type} collection
|
|
59
59
|
*/
|
|
60
60
|
constructor(collection) {
|
|
61
|
-
super(
|
|
61
|
+
super();
|
|
62
62
|
this.collection = collection;
|
|
63
|
+
this.subject = (0, io_1.formatted) `${collection}`;
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
66
|
* @desc
|
|
@@ -208,6 +209,20 @@ class List extends Question_1.Question {
|
|
|
208
209
|
answeredBy(actor) {
|
|
209
210
|
return this.collection.items(actor);
|
|
210
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* @desc
|
|
214
|
+
* Changes the description of this question's subject.
|
|
215
|
+
*
|
|
216
|
+
* @param {string} subject
|
|
217
|
+
* @returns {Question<T>}
|
|
218
|
+
*/
|
|
219
|
+
describedAs(subject) {
|
|
220
|
+
this.subject = subject;
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
toString() {
|
|
224
|
+
return this.subject;
|
|
225
|
+
}
|
|
211
226
|
static ordinalSuffixOf(index) {
|
|
212
227
|
const lastDigit = index % 10, lastTwoDigits = index % 100;
|
|
213
228
|
switch (true) {
|