@@ -10,7 +10,9 @@ describe('Test the HTTPTransport', function () {
10
10
it ( 'should check the action function of an HTTP transport (text/html)' , function ( ) {
11
11
const url = 'http://www.example.com/'
12
12
const link = new document . Link ( url , 'get' )
13
- const transport = new transports . HTTPTransport ( null , testUtils . mockedFetch ( 'Hello, world' , 'text/html' ) )
13
+ const transport = new transports . HTTPTransport ( {
14
+ fetch : testUtils . mockedFetch ( 'Hello, world' , 'text/html' )
15
+ } )
14
16
15
17
return transport . action ( link , decoders )
16
18
. then ( ( res ) => {
@@ -21,7 +23,9 @@ describe('Test the HTTPTransport', function () {
21
23
it ( 'should check the action function of an HTTP transport (json)' , function ( ) {
22
24
const url = 'http://www.example.com/'
23
25
const link = new document . Link ( url , 'get' )
24
- const transport = new transports . HTTPTransport ( null , testUtils . mockedFetch ( '{"text": "Hello, world"}' , 'application/json' ) )
26
+ const transport = new transports . HTTPTransport ( {
27
+ fetch : testUtils . mockedFetch ( '{"text": "Hello, world"}' , 'application/json' )
28
+ } )
25
29
26
30
return transport . action ( link , decoders )
27
31
. then ( res => expect ( res ) . toEqual ( { text : 'Hello, world' } ) )
@@ -40,7 +44,9 @@ describe('Test the HTTPTransport', function () {
40
44
const url = 'http://www.example.com/'
41
45
const fields = [ new document . Field ( 'firstField' , true , 'form' ) , new document . Field ( 'secondField' , true , 'form' ) ]
42
46
const link = new document . Link ( url , 'post' , 'application/x-www-form-urlencoded' , fields )
43
- const transport = new transports . HTTPTransport ( null , testUtils . echo )
47
+ const transport = new transports . HTTPTransport ( {
48
+ fetch : testUtils . echo
49
+ } )
44
50
const params = {
45
51
firstField : 'hello' ,
46
52
secondField : 'world'
@@ -60,7 +66,9 @@ describe('Test the HTTPTransport', function () {
60
66
it ( 'should check the action function of an HTTP transport (network fail)' , function ( ) {
61
67
const url = 'http://www.example.com/'
62
68
const link = new document . Link ( url , 'get' )
63
- const transport = new transports . HTTPTransport ( null , testUtils . mockedFetch ( 'ERROR' , 'text/html' , 500 ) )
69
+ const transport = new transports . HTTPTransport ( {
70
+ fetch : testUtils . mockedFetch ( 'ERROR' , 'text/html' , 500 )
71
+ } )
64
72
65
73
return transport . action ( link , decoders )
66
74
. catch ( function ( result ) {
@@ -73,7 +81,9 @@ describe('Test the HTTPTransport', function () {
73
81
const url = 'http://www.example.com/'
74
82
const fields = [ new document . Field ( 'page' , false , 'query' ) ]
75
83
const link = new document . Link ( url , 'get' , 'application/json' , fields )
76
- const transport = new transports . HTTPTransport ( null , testUtils . echo )
84
+ const transport = new transports . HTTPTransport ( {
85
+ fetch : testUtils . echo
86
+ } )
77
87
const params = {
78
88
page : 23
79
89
}
@@ -88,7 +98,9 @@ describe('Test the HTTPTransport', function () {
88
98
const url = 'http://www.example.com/{user}/'
89
99
const fields = [ new document . Field ( 'user' , true , 'path' ) ]
90
100
const link = new document . Link ( url , 'get' , 'application/json' , fields )
91
- const transport = new transports . HTTPTransport ( null , testUtils . echo )
101
+ const transport = new transports . HTTPTransport ( {
102
+ fetch : testUtils . echo
103
+ } )
92
104
const params = {
93
105
user : 23
94
106
}
@@ -102,7 +114,9 @@ describe('Test the HTTPTransport', function () {
102
114
it ( 'should check the action function of an HTTP transport (json) with post request' , function ( ) {
103
115
const url = 'http://www.example.com/'
104
116
const link = new document . Link ( url , 'post' )
105
- const transport = new transports . HTTPTransport ( null , testUtils . echo )
117
+ const transport = new transports . HTTPTransport ( {
118
+ fetch : testUtils . echo
119
+ } )
106
120
107
121
return transport . action ( link , decoders )
108
122
. then ( ( res ) => {
@@ -114,7 +128,10 @@ describe('Test the HTTPTransport', function () {
114
128
const url = 'http://www.example.com/'
115
129
const link = new document . Link ( url , 'post' )
116
130
const csrf = { 'X-CSRFToken' : 'abc' }
117
- const transport = new transports . HTTPTransport ( csrf , testUtils . echo )
131
+ const transport = new transports . HTTPTransport ( {
132
+ csrf : csrf ,
133
+ fetch : testUtils . echo
134
+ } )
118
135
119
136
return transport . action ( link , decoders )
120
137
. then ( ( res ) => {
@@ -126,7 +143,10 @@ describe('Test the HTTPTransport', function () {
126
143
const url = 'http://www.example.com/'
127
144
const link = new document . Link ( url , 'get' )
128
145
const csrf = { 'X-CSRFToken' : 'abc' }
129
- const transport = new transports . HTTPTransport ( csrf , testUtils . echo )
146
+ const transport = new transports . HTTPTransport ( {
147
+ csrf : csrf ,
148
+ fetch : testUtils . echo
149
+ } )
130
150
131
151
return transport . action ( link , decoders )
132
152
. then ( ( res ) => {
@@ -138,7 +158,9 @@ describe('Test the HTTPTransport', function () {
138
158
const url = 'http://www.example.com/'
139
159
const fields = [ new document . Field ( 'hello' , true , 'form' ) ]
140
160
const link = new document . Link ( url , 'post' , 'application/json' , fields )
141
- const transport = new transports . HTTPTransport ( null , testUtils . echo )
161
+ const transport = new transports . HTTPTransport ( {
162
+ fetch : testUtils . echo
163
+ } )
142
164
const params = {
143
165
hello : 'world'
144
166
}
@@ -153,7 +175,9 @@ describe('Test the HTTPTransport', function () {
153
175
const url = 'http://www.example.com/'
154
176
const fields = [ new document . Field ( 'hello' , true , 'body' ) ]
155
177
const link = new document . Link ( url , 'post' , 'application/json' , fields )
156
- const transport = new transports . HTTPTransport ( null , testUtils . echo )
178
+ const transport = new transports . HTTPTransport ( {
179
+ fetch : testUtils . echo
180
+ } )
157
181
const params = {
158
182
hello : 'world'
159
183
}
@@ -168,7 +192,9 @@ describe('Test the HTTPTransport', function () {
168
192
const url = 'http://www.example.com/'
169
193
const fields = [ new document . Field ( 'page' , false , 'query' ) ]
170
194
const link = new document . Link ( url , 'get' , 'application/json' , fields )
171
- const transport = new transports . HTTPTransport ( null , testUtils . echo )
195
+ const transport = new transports . HTTPTransport ( {
196
+ fetch : testUtils . echo
197
+ } )
172
198
const params = { }
173
199
174
200
return transport . action ( link , decoders , params )
@@ -181,7 +207,9 @@ describe('Test the HTTPTransport', function () {
181
207
const url = 'http://www.example.com/{user}/'
182
208
const fields = [ new document . Field ( 'user' , true , 'path' ) ]
183
209
const link = new document . Link ( url , 'get' , 'application/json' , fields )
184
- const transport = new transports . HTTPTransport ( null , testUtils . echo )
210
+ const transport = new transports . HTTPTransport ( {
211
+ fetch : testUtils . echo
212
+ } )
185
213
const params = { }
186
214
187
215
const callTransport = ( ) => transport . action ( link , decoders , params )
@@ -191,7 +219,9 @@ describe('Test the HTTPTransport', function () {
191
219
it ( 'should check the action function of an HTTP transport (json) with unknown paramater' , function ( ) {
192
220
const url = 'http://www.example.com/'
193
221
const link = new document . Link ( url , 'get' )
194
- const transport = new transports . HTTPTransport ( null , testUtils . echo )
222
+ const transport = new transports . HTTPTransport ( {
223
+ fetch : testUtils . echo
224
+ } )
195
225
const params = {
196
226
hello : 'world'
197
227
}
0 commit comments