-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
43 lines (32 loc) · 921 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"use strict";
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var assert = _interopRequire(require("assert"));
var sinon = _interopRequire(require("sinon"));
var ajax = _interopRequire(require("./"));
var xhr, requests;
before(function () {
xhr = sinon.useFakeXMLHttpRequest();
requests = [];
xhr.onCreate = function (req) {
requests.push(req);
};
});
after(function () {
xhr.restore();
});
it("fd-ajax", function () {
var spy = sinon.spy();
assert.equal(typeof ajax, "function");
ajax("test.com")(spy);
assert.equal(requests.length, 1);
assert(spy.called);
assert.equal(requests[0].url, "test.com");
spy.reset();
requests = [];
ajax({ url: "foo" })(spy);
assert.equal(requests.length, 1);
assert(spy.called);
assert.equal(requests[0].url, "foo");
spy.reset();
requests = [];
});