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
+3-6
Original file line number
Diff line number
Diff line change
@@ -137,19 +137,16 @@ function getTodos(listId, callback) {
137
137
});
138
138
}
139
139
```
140
-
141
-
To test this function without triggering network activity we could replace `jQuery.ajax`
140
+
A unit test should not actually trigger a function's network activity. To test `getTodos()` without triggering its network activity, use the `sinon.replace()` method to replace the `jQuery.ajax` method in your test. Restore the `jQuery.ajax` method after your test by calling `sinon.restore()` in your test runner's `after()` function.
142
141
143
142
```javascript
144
143
after(function () {
145
-
// When the test either fails or passes, restore the original
146
-
// jQuery ajax function (Sinon.JS also provides tools to help
147
-
// test frameworks automate clean-up like this)
148
-
jQuery.ajax.restore();
144
+
sinon.restore();
149
145
});
150
146
151
147
it('makes a GET request for todo items', function () {
0 commit comments