Skip to content

Commit

Permalink
Add documentation for "has" matcher on embedded objects (#1422)
Browse files Browse the repository at this point in the history
  • Loading branch information
mareq authored and mantoni committed May 25, 2017
1 parent 15871b2 commit ebe37da
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/release-source/release/matchers.md
Expand Up @@ -12,13 +12,18 @@ corresponding `sinon.assert` functions as well as `spy.withArgs`. Matchers allow
var book = {
pages: 42,
author: "cjno"
id: {
isbn10: "0596517742",
isbn13: "978-0596517748"
}
};
var spy = sinon.spy();

spy(book);

sinon.assert.calledWith(spy, sinon.match({ author: "cjno" }));
sinon.assert.calledWith(spy, sinon.match.has("pages", 42));
sinon.assert.calledWith(spy, sinon.match.has("id", sinon.match.has("isbn13", "978-0596517748")));
}
```

Expand Down
10 changes: 10 additions & 0 deletions test/match-test.js
Expand Up @@ -555,6 +555,16 @@ describe("sinonMatch", function () {
assert(has.test({ prop: symbol }));
}
});

it("returns true if embedded object has Symbol", function () {
if (typeof Symbol === "function") {
var symbol = Symbol();

var has = sinonMatch.has("prop", sinonMatch.has("embedded", symbol));

assert(has.test({ prop: { embedded: symbol }, ignored: 42 }));
}
});
});

describe(".hasOwnSpecial", function () {
Expand Down

0 comments on commit ebe37da

Please sign in to comment.