Ben Loveridge
unread,Jan 13, 2011, 12:39:27 PM1/13/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Jasmine
Hi,
In one of my functions, I am invoking an async API which expects a few
parameters, with the last one being a callback function. Due to some
variables that need to be available in the callback function, I am
using an anonymous function as the callback so the callback has scope
reference to those variables.
When testing this function, I am trying to verify that the
asynchronous API is called with the correct parameters -- since the
callback provided is an anonymous function, I can't seem to do it.
expect(the.function).toHaveBeenCalledWith(a, b, c); // doesnt work,
because the 4th parameter was a function which we didn't tell Jasmine
about
Short of writing a custom matcher, is there a way to expect a
parameter to just be anything of a given type? Something like this
comes to mind:
expect(the.function).toHaveBeenCalledWith(a, b, c,
jasmine.typeof("function"));
Thanks in advance for any help or guidance.
- Ben