@@ -27,6 +27,33 @@ describe('Test the HTTPTransport', function () {
27
27
. then ( res => expect ( res ) . toEqual ( { text : 'Hello, world' } ) )
28
28
} )
29
29
30
+ xit ( 'should check the action function of an HTTP transport (multipart/form-data)' , function ( ) {
31
+ const url = 'http://www.example.com/'
32
+ const link = new document . Link ( url , 'get' , 'multipart/form-data' )
33
+ const transport = new transports . HTTPTransport ( testUtils . mockedFetch ( '{"text": "Hello, world"}' , 'application/json' ) )
34
+
35
+ return transport . action ( link , decoders )
36
+ . then ( res => expect ( res ) . toEqual ( { text : 'Hello, world' } ) )
37
+ } )
38
+
39
+ it ( 'should check the action function of an HTTP transport (application/x-www-form-urlencoded)' , function ( ) {
40
+ const url = 'http://www.example.com/'
41
+ const fields = [ new document . Field ( 'firstField' , true , 'form' ) , new document . Field ( 'secondField' , true , 'form' ) ]
42
+ const link = new document . Link ( url , 'post' , 'application/x-www-form-urlencoded' , fields )
43
+ const transport = new transports . HTTPTransport ( testUtils . echo )
44
+ const params = {
45
+ firstField : 'hello' ,
46
+ secondField : 'world'
47
+ }
48
+
49
+ return transport . action ( link , decoders , params )
50
+ . then ( res => expect ( res ) . toEqual ( {
51
+ body : 'firstField=hello&secondField=world' ,
52
+ method : 'post' ,
53
+ url : 'http://www.example.com/'
54
+ } ) )
55
+ } )
56
+
30
57
it ( 'should check the action function of an HTTP transport (network fail)' , function ( ) {
31
58
const url = 'http://www.example.com/'
32
59
const link = new document . Link ( url , 'get' )
@@ -87,7 +114,7 @@ describe('Test the HTTPTransport', function () {
87
114
88
115
return transport . action ( link , decoders , params )
89
116
. then ( ( res ) => {
90
- expect ( res ) . toEqual ( { url : 'http://www.example.com/' , metho
6D4E
d : 'post' , body : { hello : 'world' } } )
117
+ expect ( res ) . toEqual ( { url : 'http://www.example.com/' , method : 'post' , body : JSON . stringify ( { hello : 'world' } ) } )
91
118
} )
92
119
} )
93
120
@@ -102,7 +129,7 @@ describe('Test the HTTPTransport', function () {
102
129
103
130
return transport . action ( link , decoders , params )
104
131
. then ( ( res ) => {
105
- expect ( res ) . toEqual ( { url : 'http://www.example.com/' , method : 'post' , body : 'world' } )
132
+ expect ( res ) . toEqual ( { url : 'http://www.example.com/' , method : 'post' , body : JSON . stringify ( 'world' ) } )
106
133
} )
107
134
} )
108
135
0 commit comments