1(function(QUnit) { 2 3 var sync = Backbone.sync; 4 var ajax = Backbone.ajax; 5 var emulateHTTP = Backbone.emulateHTTP; 6 var emulateJSON = Backbone.emulateJSON; 7 var history = window.history; 8 var pushState = history.pushState; 9 var replaceState = history.replaceState; 10 11 QUnit.config.noglobals = true; 12 13 QUnit.testStart(function() { 14 var env = QUnit.config.current.testEnvironment; 15 16 // We never want to actually call these during tests. 17 history.pushState = history.replaceState = function() {}; 18 19 // Capture ajax settings for comparison. 20 Backbone.ajax = function(settings) { 21 env.ajaxSettings = settings; 22 }; 23 24 // Capture the arguments to Backbone.sync for comparison. 25 Backbone.sync = function(method, model, options) { 26 env.syncArgs = { 27 method: method, 28 model: model, 29 options: options 30 }; 31 sync.apply(this, arguments); 32 }; 33 34 }); 35 36 QUnit.testDone(function() { 37 Backbone.sync = sync; 38 Backbone.ajax = ajax; 39 Backbone.emulateHTTP = emulateHTTP; 40 Backbone.emulateJSON = emulateJSON; 41 history.pushState = pushState; 42 history.replaceState = replaceState; 43 }); 44 45})(QUnit); 46