forked from cujojs/rest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient-test.js
65 lines (55 loc) · 1.98 KB
/
client-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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Copyright 2014 the original author or authors
* @license MIT, see LICENSE.txt for details
*
* @author Scott Andrews
*/
(function (buster, define) {
'use strict';
var assert, refute, fail, failOnThrow;
assert = buster.assertions.assert;
refute = buster.assertions.refute;
fail = buster.assertions.fail;
failOnThrow = buster.assertions.failOnThrow;
define('rest-test/client-test', function (require) {
var client, rest, interceptor, defaultClient, skippableClient, defaultInterceptor;
client = require('rest/client');
rest = require('rest/client/default');
interceptor = require('rest/interceptor');
buster.testCase('rest/client', {
'setUp': function () {
defaultClient = client(function (request) {
return { request: request, id: 'default' };
});
skippableClient = client(function (request) {
return { request: request, id: 'default' };
}, rest);
defaultInterceptor = interceptor();
},
'should wrap the client with an interceptor': function () {
assert(typeof defaultClient.wrap(defaultInterceptor) === 'function');
},
'should continue to support chain as a alias for wrap': function () {
var config = {};
this.spy(defaultClient, 'wrap');
defaultClient.chain(defaultInterceptor, config);
assert.calledWith(defaultClient.wrap, defaultInterceptor, config);
defaultClient.wrap.restore();
},
'should return the next client in the chain': function () {
assert.same(rest, skippableClient.skip());
refute(defaultClient.skip);
}
});
});
}(
this.buster || require('buster'),
typeof define === 'function' && define.amd ? define : function (id, factory) {
var packageName = id.split(/[\/\-]/)[0], pathToRoot = id.replace(/[^\/]+/g, '..');
pathToRoot = pathToRoot.length > 2 ? pathToRoot.substr(3) : pathToRoot;
factory(function (moduleId) {
return require(moduleId.indexOf(packageName) === 0 ? pathToRoot + moduleId.substr(packageName.length) : moduleId);
});
}
// Boilerplate for AMD and Node
));