@serenity-js/core
Version:
The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure
36 lines • 1.02 kB
JavaScript
import { ValueInspector } from '../../io/reflection/index.js';
const descriptionField = Symbol('description');
/**
* @group Questions
*/
export class Describable {
[descriptionField];
constructor(description) {
this[descriptionField] = description;
}
/**
* Resolves the description of this object in the context of the provided `actor`.
*
* @param actor
*/
async describedBy(actor) {
const description = await actor.answer(this[descriptionField]);
return description.replaceAll('#actor', actor.name);
}
setDescription(description) {
this[descriptionField] = description;
}
getDescription() {
return this[descriptionField];
}
/**
* Returns a human-readable description of this object.
*/
toString() {
if (ValueInspector.isPromise(this[descriptionField])) {
return 'Promise';
}
return String(this[descriptionField]);
}
}
//# sourceMappingURL=Describable.js.map