3 category: JavaScript libraries
29 $.ajax.calledOnce == true
33 sinon.stub($, 'ajax', function () { ... }) // function optional
37 $.ajax.calledWithMatch({ url: '/x' })
41 ### Spy/stub properties
45 .args //=> [ [..], [..] ] one per call
60 .getCalls() //=> Array
68 stub = sinon.stub().returns(42)
74 .withArgs(42).returns(1)
75 .withArgs(43).throws("TypeError")
82 .returnsArg(0) // Return 1st argument
89 sinon.useFakeTimers(+new Date(2011,9,1));
95 server = sinon.fakeServer.create()
99 $.get('/file.json', ...)
100 server.requests[0].respond(
102 { 'Content-Type': 'application/json' },
103 JSON.stringify({ hello: 'world' })
114 xhr = sinon.useFakeXMLHttpRequest()
121 beforeEach(function() {
122 global.sinon = require('sinon').sandbox.create()
127 afterEach(function() {
128 global.sinon.restore()