I'm testing an api with the wonderful Mocha and Should.js.
I do a GET and receive an array of objects, for example:
[{
username: 'boris',
something: 123
},
{
username: 'jeremy',
something: 456
},
{
username: 'steven',
something: 789
},
{ ... },
{ ... },
{ ... }]
For each object, I want to make sure that the username value matches a property in a different object:
mockUsernames = {
a : 'bill',
b : 'ben',
c : 'boris'
};
How can you achieve this? As an example I want something like this:
.get()
...
var someData = res.body;
someData.forEach(function (e){
e.username.should.equal(mockUsernames.a || mockUsernames.b || mockUsernames.c);
});
...
As expected this doesn't work as I want because should.equal
uses equal comparison operator.
Any recommended should.js methods would be v.appreciated. I can't seem to find what I want, or maybe this should be approached differently.