February 2015
Intermediate to advanced
392 pages
8h 12m
English
We will continue coding our tests, assuming that our API uses promises but that the DAO uses callbacks. If you tried to make your first scenario pass, then you would end up with something similar to what I have in my project in the lib/orders.js file:
var Q = require('q');
module.exports = function () {
return {
display: function (orderId) {
return Q.fulfill({
items: [],
totalPrice: 0,
actions: [
{
action: 'append-beverage',
target: orderId,
parameters: {
beverageRef: null,
quantity: 0
}
}
]
});
}
};
};No orderDAO anywhere! In fact, we can remove all references to orderDAO in the setup or our test! What happened is that we introduced it prematurely. This is something we would not have done in real circumstances but, for ...
Read now
Unlock full access