@incdevco/framework
Version:
node.js lambda framework
64 lines (36 loc) • 1.61 kB
JavaScript
var Expect = require('chai').expect;
var Mock = require('../index');
var Expectation = require('./index');
describe('mock/expectation', function () {
'use strict';
it('should set _will to "executeCallback" and store submitted arguments in _callbackArguments', function () {
var arg1 = 'arg1', arg2 = 'arg2', expectation = new Expectation();
expectation.willExecuteCallback(arg1, arg2);
Expect(expectation._will).to.equal('executeCallback', 'expectation._will');
Expect(expectation._callbackArguments).to.deep.equal([
arg1,
arg2
], 'expectation._callbackArguments');
});
it('should set _reflect to submitted value', function() {
var value = 'value', expectation = new Expectation();
expectation.willReflect(value);
Expect(expectation._reflect).to.equal(value, 'expectation._reflect');
});
describe('willReturnAwsPromiseReject', function() {
it('should call willReturn with an object with a promise function that rejects with the submitted value', function (done) {
var value = 'value', expectation = new Expectation();
expectation.willReturnAwsPromiseReject(value);
Expect(expectation._will).to.equal('return', '_will');
expectation._return.promise()
.then(function () {
throw new Error('resolved');
})
.catch(function (actual) {
Expect(actual).to.equal(value, 'rejected value');
return done();
})
.catch(done);
});
});
});