1 | global.expect = require('chai').expect;
|
2 | global.sinon = require('sinon');
|
3 | global.portals = require('../portals')
|
4 |
|
5 | /**
|
6 | * @beforeEach
|
7 | */
|
8 | beforeEach(function () {
|
9 | // stub xhr
|
10 | this.xhr = sinon.useFakeXMLHttpRequest();
|
11 | global.XMLHttpRequest = this.xhr;
|
12 |
|
13 | // array for storing made requests
|
14 | this.requests = [];
|
15 |
|
16 | // push requests onto our requests array
|
17 | this.xhr.onCreate = function (xhr) {
|
18 | this.requests.push(xhr);
|
19 | }.bind(this);
|
20 | });
|
21 |
|
22 | /**
|
23 | * @afterEach
|
24 | */
|
25 | afterEach(function () {
|
26 | // put xhr back
|
27 | delete global.XMLHttpRequest;
|
28 | this.xhr.restore();
|
29 | });
|