You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/index.md
-64Lines changed: 0 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -156,67 +156,6 @@ it("makes a GET request for todo items", function () {
156
156
});
157
157
```
158
158
159
-
### Fake XMLHttpRequest
160
-
161
-
While the preceding test shows off some nifty Sinon.JS tricks, it is too tightly coupled to the implementation. When testing Ajax, it is better to use Sinon.JS' [fake XMLHttpRequest][fakexhr]:
162
-
163
-
```javascript
164
-
var xhr, requests;
165
-
166
-
before(function () {
167
-
xhr =sinon.useFakeXMLHttpRequest();
168
-
requests = [];
169
-
xhr.onCreate=function (req) {
170
-
requests.push(req);
171
-
};
172
-
});
173
-
174
-
after(function () {
175
-
// Like before we must clean up when tampering with globals.
176
-
xhr.restore();
177
-
});
178
-
179
-
it("makes a GET request for todo items", function () {
180
-
getTodos(42, sinon.fake());
181
-
182
-
assert.equals(requests.length, 1);
183
-
assert.match(requests[0].url, "/todo/42/items");
184
-
});
185
-
```
186
-
187
-
Learn more about [fake XMLHttpRequest][fakexhr].
188
-
189
-
### Fake server
190
-
191
-
The preceding example shows how flexible this API is. If it looks too laborious, you may like the fake server:
192
-
193
-
```javascript
194
-
var server;
195
-
196
-
before(function () {
197
-
server =sinon.fakeServer.create();
198
-
});
199
-
after(function () {
200
-
server.restore();
201
-
});
202
-
203
-
it("calls callback with deserialized data", function () {
0 commit comments