forked from taigaio/taiga-front
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-utils.js
43 lines (35 loc) · 1.04 KB
/
test-utils.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
/*
* This source code is licensed under the terms of the
* GNU Affero General Public License found in the LICENSE file in
* the root directory of this source tree.
*
* Copyright (c) 2021-present Kaleidos INC
*/
(function() {
var searchOriginal = function(obj) {
if (obj._promise) {
return obj;
} else {
return searchOriginal(obj.parent);
}
};
sinon.stub.promise = function() {
var obj = this;
var returnedPromise = new Promise(function(_resolve_, _reject_){
obj._resolvefn = _resolve_;
obj._rejectfn = _reject_;
});
this.returns(returnedPromise);
this._promise = true;
return this;
};
sinon.stub.resolve = function() {
var original = searchOriginal(this);
original._resolvefn.apply(this, arguments);
};
sinon.stub.reject = function() {
var original = searchOriginal(this);
original._rejectfn.apply(this, arguments);
};
window.addDecorator = function() {};
}());