Skip to content

Commit 21bf561

Browse files
committed
fixup! fix: refactor assets, settings/main, pages/index specs to not call AjaxHelpers inside it()
1 parent df7b4a0 commit 21bf561

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

cms/static/js/spec/views/assets_spec.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ function($, sinon, AjaxHelpers, URI, AssetsView, AssetCollection, ViewHelpers) {
1111
uploadModalTpl = readFixtures('asset-upload-modal.underscore');
1212

1313
beforeEach(function() {
14-
xhrFactory = sinon.useFakeXMLHttpRequest();
15-
requests = [];
16-
requests.currentIndex = 0;
17-
requests.restore = function() { xhrFactory.restore(); };
18-
xhrFactory.onCreate = function(req) { requests.push(req); };
1914
setFixtures($('<script>', {id: 'asset-library-tpl', type: 'text/template'}).text(assetLibraryTpl));
2015
appendSetFixtures($('<script>', {id: 'asset-tpl', type: 'text/template'}).text(assetTpl));
2116
appendSetFixtures(uploadModalTpl);
@@ -36,7 +31,14 @@ function($, sinon, AjaxHelpers, URI, AssetsView, AssetCollection, ViewHelpers) {
3631
el: $('#asset_table_body')
3732
});
3833

39-
assetsView.render();
34+
// Install fake XHR after creating assetsView so that the initial setPage(1)
35+
// fired by createPagingView() during initialize() is not captured. Tests that
36+
// need a specific page state drive it themselves via setPage() + respond.
37+
xhrFactory = sinon.useFakeXMLHttpRequest();
38+
requests = [];
39+
requests.currentIndex = 0;
40+
requests.restore = function() { xhrFactory.restore(); };
41+
xhrFactory.onCreate = function(req) { requests.push(req); };
4042
});
4143

4244
afterEach(function() {

0 commit comments

Comments
 (0)