Help with Google Closure test framework? esp. mocking XhrIo

I come from a C++ background, and am familiar with googlemock and such from that end. I'm on a javascript project now that uses the Google Closure framework, and I'm trying to get a feel for how to write unit tests with mocks. The existing code in the project doesn't appear to use mocks, and the O'Reilly book doesn't really spend a lot of time discussing how to use them.

I was wondering if anyone knew of a good online tutorial/resource to see more of their use in practice. Even some open source projects already using them that I can see the pattern in would be helpful.

Thanks

1 comments · 100% upvoted · other discussions

comments

joenyc

I don't know that there are any big open source projects that use Closure, unfortunately, but we use it heavily at my job, so maybe I can answer specific questions? When you say "the O'Reilly book", you mean Closure the Definitive Guide?

Specifically regarding XhrIo, we abstract the network layer entirely and use a testing-specific fake in our tests, sort of like goog.testing.net.XhrIo.