Reputation: 10346
Is it possible doing in Chai something like?:
expect(message).to.have.property('key1', value).or.to.have.property('key2', value);
So I mean, property one OR property two have the value.
Upvotes: 0
Views: 483
Reputation: 4079
This could work as long as value !== undefined
and message
exists
expect([message.key1, message.key2]).to.include(value);
Alternatively you could use satisfy
:
expect(message).to.satisfy(msg => {
if (msg.key1 && msg.key1 === value) return true;
if (msg.key2 && msg.key2 === value) return true;
return false;
})
Upvotes: 1