testdouble-chai icon indicating copy to clipboard operation
testdouble-chai copied to clipboard

calledWith format

Open LandonSchropp opened this issue 7 years ago • 2 comments

Thanks for creating such a handy little library!

The output of calledWith with seems to be a bit broken when using the contains matcher. Here's what I get when using testdouble.verify:

testdouble.verify(requestMock(testdouble.matchers.contains({
  headers: { "Authorization": "Bearer ACCESS_TOKEN" },
  method: "GET"
})));
Wanted:
    - called with `(contains({headers: {Authorization: "Bearer ACCESS_TOKEN"}, method: "GET"}))`.

  But was actually called:
    - called with `({
  method: "POST",
  url: "http://graph:8989/api/query",
  headers: {Authorization: "Bearer ACCESS_TOKEN"},
  json: {"@class": ".Query"}
})`.

And this is the output when running with testdouble-chai:

expect(requestMock).to.have.been.calledWith(testdouble.matchers.contains({
  headers: { "Authorization": "Bearer ACCESS_TOKEN" },
  method: "GET"
}));
       [
         {
      -    "headers": {
      -      "Authorization": "Bearer ACCESS_TOKEN"
      -    }
      -    "json": {
      -      "@class": ".Query"
      -    }
      -    "method": "POST"
      -    "url": "http://graph:8989/api/query"
      +    "__matches": [Function]
      +    "__name": "contains({headers: {Authorization: \"Bearer ACCESS_TOKEN\"}, method: \"GET\"})"
         }
       ]

LandonSchropp avatar Dec 06 '16 21:12 LandonSchropp