exports.mockSuccessObj = {
doATask: emptyPromises()
};
exports.mockFailObj = {
doATask: emptyPromises(null, new Error('Task failed!'))
};
const test = require('tape');
const mocks = require('./mocks');
test('it works when it works', (t) => {
const aBusinessObject = aBusinessObjectFactory(mocks.mockSuccessObj);
aBusinessObject.doStuffThatInvolvesMock()
.then(() => {
t.end('Yay!');
})
.catch((e) => {
t.fail('I should not be here');
});
});
test('it fails when it fails', (t) => {
const aBusinessObject = aBusinessObjectFactory(mocks.mockFailObj);
aBusinessObject.doStuffThatInvolvesMock()
.then(() => {
t.fail('I should not be here');
})
.catch((e) => {
t.equal(e.message, 'Task failed!');
t.end('You have failed and that is a good thing!');
});
});