@serenity-js/core
Version:
The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure
40 lines • 1.18 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Describable = void 0;
const ValueInspector_1 = require("../../io/reflection/ValueInspector");
const descriptionField = Symbol('description');
/**
* @group Questions
*/
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_1.ValueInspector.isPromise(this[descriptionField])) {
return 'Promise';
}
return String(this[descriptionField]);
}
}
exports.Describable = Describable;
//# sourceMappingURL=Describable.js.map
;