4
4
/* globals sinon */
5
5
6
6
import * as u from '../src/apiUtility.js' ;
7
- import * as utility from '../src/utility.js' ;
8
- utility . setupJSON ( ) ;
9
7
10
8
describe ( 'buildPayload' , function ( ) {
11
9
it ( 'should package up the input into a payload' , function ( ) {
@@ -18,10 +16,7 @@ describe('buildPayload', function () {
18
16
it ( 'should stringify context' , function ( ) {
19
17
var token = 'abc123' ;
20
18
var context = { a : 1 , b : 'other' } ;
21
- var data = {
22
- context : context ,
23
- other : 'stuff' ,
24
- } ;
19
+ var data = { context : context , other : 'stuff' } ;
25
20
var payload = u . buildPayload ( data ) ;
26
21
27
22
expect ( payload . data . context ) . to . not . eql ( context ) ;
@@ -33,10 +28,7 @@ describe('buildPayload', function () {
33
28
for ( var i = 0 ; i < 35 ; i ++ ) {
34
29
context [ i ] = i ;
35
30
}
36
- var data = {
37
- context : context ,
38
- other : 'stuff' ,
39
- } ;
31
+ var data = { context : context , other : 'stuff' } ;
40
32
var payload = u . buildPayload ( data ) ;
41
33
42
34
expect ( payload . data . context ) . to . not . eql ( context ) ;
@@ -48,17 +40,10 @@ describe('getTransportFromOptions', function () {
48
40
it ( 'should use defaults with not endpoint' , function ( ) {
49
41
var options = {
50
42
not : 'endpoint' ,
51
- proxy : {
52
- host : 'whatver.com' ,
53
- port : 9090 ,
54
- } ,
43
+ proxy : { host : 'whatver.com' , port : 9090 } ,
55
44
timeout : 3000 ,
56
45
} ;
57
- var defaults = {
58
- hostname : 'api.com' ,
59
- protocol : 'https:' ,
60
- path : '/api/1' ,
61
- } ;
46
+ var defaults = { hostname : 'api.com' , protocol : 'https:' , path : '/api/1' } ;
62
47
var url = {
63
48
parse : function ( ) {
64
49
expect ( false ) . to . be . ok ( ) ;
@@ -75,10 +60,7 @@ describe('getTransportFromOptions', function () {
75
60
it ( 'should parse the endpoint if given' , function ( ) {
76
61
var options = {
77
62
endpoint : 'http://whatever.com/api/42' ,
78
- proxy : {
79
- host : 'nope.com' ,
80
- port : 9090 ,
81
- } ,
63
+ proxy : { host : 'nope.com' , port : 9090 } ,
82
64
} ;
83
65
var defaults = {
84
66
hostname : 'api.com' ,
@@ -161,11 +143,7 @@ describe('getTransportFromOptions', function () {
161
143
162
144
describe ( 'transportOptions' , function ( ) {
163
145
it ( 'should use the given data if no proxy' , function ( ) {
164
- var transport = {
165
- hostname : 'a.com' ,
166
- path : '/api/v1/item/' ,
167
- port : 5000 ,
168
- } ;
146
+ var transport = { hostname : 'a.com' , path : '/api/v1/item/' , port : 5000 } ;
169
147
var method = 'GET' ;
170
148
171
149
var o = u . transportOptions ( transport , method ) ;
@@ -181,10 +159,7 @@ describe('transportOptions', function () {
181
159
hostname : 'a.com' ,
182
160
path : '/api/v1/item/' ,
183
161
port : 5000 ,
184
- proxy : {
185
- host : 'b.com' ,
186
- port : 8080 ,
187
- } ,
162
+ proxy : { host : 'b.com' , port : 8080 } ,
188
163
timeout : 3000 ,
189
164
} ;
190
165
var method = 'GET' ;
0 commit comments