@incdevco/framework
Version:
node.js lambda framework
129 lines (78 loc) • 1.99 kB
JavaScript
var Promise = require('bluebird');
function Expectation() {
"use strict";
this._callbackArguments = undefined;
this._met = false;
this._reflect = undefined;
this._reject = undefined;
this._resolve = undefined;
this._return = undefined;
this._will = undefined;
this._withArgs = [];
}
Expectation.prototype.met = function () {
"use strict";
return this._met;
};
Expectation.prototype.willCauseSideEffect = function (fn) {
'use strict';
this._sideEffect = fn;
return this;
};
Expectation.prototype.willExecuteCallback = function () {
"use strict";
this._will = "executeCallback";
this._callbackArguments = Array.prototype.slice.call(arguments);
return this;
};
Expectation.prototype.willReflect = function (value) {
"use strict";
this._reflect = value;
return this;
};
Expectation.prototype.willReject = function (value) {
"use strict";
this._will = 'reject';
this._reject = value;
return this;
};
Expectation.prototype.willResolve = function (value) {
"use strict";
this._will = 'resolve';
this._resolve = value;
return this;
};
Expectation.prototype.willReturn = function (value) {
"use strict";
this._will = 'return';
this._return = value;
return this;
};
Expectation.prototype.willReturnAwsPromiseReject = function (value) {
'use strict';
return this.willReturn({
promise: function () {
return Promise.reject(value);
}
});
};
Expectation.prototype.willReturnAwsPromiseResolve = function (value) {
'use strict';
return this.willReturn({
promise: function () {
return Promise.resolve(value);
}
});
};
Expectation.prototype.willThrow = function (value) {
"use strict";
this._will = 'throw';
this._throw = value;
return this;
};
Expectation.prototype.with = function () {
"use strict";
this._withArgs = Array.prototype.slice.call(arguments);
return this;
};
module.exports = Expectation;