Open aseemk opened 12 years ago
+1 I'd be nice to have
var resp = {
one : 1,
two : 2,
three : 3
};
expect(resp).to.contain({
one: 1,
two : 2
}); // true
expect(resp).not.to.contain({
three: "not a number"
}); // true (.not)
It's a more readable way of saying
expect(resp).to.have.keys("one", "two");
expect(resp.one).to.be(1);
expect(resp.two).to.be(2);
@piuccio how about adding an expect().to.have.properties()
assertion? This follows from expect().to.have.property(name, [value])
, just with the ability to provide an object to properties()
.
Hey there,
Great work on the library -- I really like it.
In writing tests against a REST API, I'd find it really convenient to check that response objects, which can have many properties and values, contain some particular properties and values.
@visionmedia's should.js has
include()
for this kind of thing, and it's really helpful:https://github.com/visionmedia/should.js#includeobj
Here it might be e.g.:
But whereas should's
include()
is for checking presence in arrays and strings too, I see that expect hascontain()
for those. So maybe this could be added intocontain()
, but maybe not.What do you think? Thanks!