I am trying to run unit tests against every item in a collection using Vows.js and I'm having a heck of a time getting it to work. Here is what I have at the moment.
'the variations objects': {
topic: function() {
var promise = new(events.EventEmitter),
variations = JSON.parse(body).variations;
for(var i = variations.length - 1; i >= 0; i--) {
promise.emit("success", variations[i]);
};
return promise;
},
'should have an x': function(topic) {
should.exist(topic.x);
},
'should have an action on the add_to_cart object if the product is IN_STOCK': function(topic) {
if(topic.x.id === 'TEST'){
should.exist(topic.x.action)
}
}
}
This seems like it is working. However, when I run the tests, I get 34 passed and 1 error. Vows does not indicate what test is erroring. I don't feel like using an EventEmitter
is the right choice for this, but I'm not sure how else to have a new topic for each object in a given collection.