Completed
Push — master ( e2c47b...19fc28 )
by Felipe
52s
created

test/setup/environment.js   A

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 45
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 45
rs 10
wmc 6
mnd 0
bc 6
fnc 6
bpm 1
cpm 1
noi 9
1
(function (window, QUnit, undefined) {
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
})(window, QUnit);
46