dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
32 lines (31 loc) • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntityActionStub = void 0;
const isString_js_1 = require("../../../utils/validation/isString.js");
const constants_js_1 = require("./constants.js");
class EntityActionStub {
constructor(spy, Action) {
this[constants_js_1.$spy] = spy;
this[constants_js_1.$actionName] = Action.actionName;
}
resolve(response) {
this[constants_js_1.$spy][constants_js_1.$mocks][this[constants_js_1.$actionName]] = () => response;
return this[constants_js_1.$spy];
}
reject(error) {
this[constants_js_1.$spy][constants_js_1.$mocks][this[constants_js_1.$actionName]] = () => {
if (error === undefined || (0, isString_js_1.isString)(error)) {
throw new Error(error);
}
else {
throw error;
}
};
return this[constants_js_1.$spy];
}
mock(mock) {
this[constants_js_1.$spy][constants_js_1.$mocks][this[constants_js_1.$actionName]] = mock;
return this[constants_js_1.$spy];
}
}
exports.EntityActionStub = EntityActionStub;