Skip to content

Commit ebe37da

Browse files
mareqmantoni
authored andcommitted
Add documentation for "has" matcher on embedded objects (#1422)
1 parent 15871b2 commit ebe37da

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

docs/release-source/release/matchers.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ corresponding `sinon.assert` functions as well as `spy.withArgs`. Matchers allow
1212
var book = {
1313
pages: 42,
1414
author: "cjno"
15+
id: {
16+
isbn10: "0596517742",
17+
isbn13: "978-0596517748"
18+
}
1519
};
1620
var spy = sinon.spy();
1721

1822
spy(book);
1923

2024
sinon.assert.calledWith(spy, sinon.match({ author: "cjno" }));
2125
sinon.assert.calledWith(spy, sinon.match.has("pages", 42));
26+
sinon.assert.calledWith(spy, sinon.match.has("id", sinon.match.has("isbn13", "978-0596517748")));
2227
}
2328
```
2429

test/match-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,16 @@ describe("sinonMatch", function () {
555555
assert(has.test({ prop: symbol }));
556556
}
557557
});
558+
559+
it("returns true if embedded object has Symbol", function () {
560+
if (typeof Symbol === "function") {
561+
var symbol = Symbol();
562+
563+
var has = sinonMatch.has("prop", sinonMatch.has("embedded", symbol));
564+
565+
assert(has.test({ prop: { embedded: symbol }, ignored: 42 }));
566+
}
567+
});
558568
});
559569

560570
describe(".hasOwnSpecial", function () {

0 commit comments

Comments
 (0)