@@ -101,16 +101,15 @@ describe('browser', function(){
101
101
102
102
it ( 'should set headers for all requests' , function ( ) {
103
103
var code , response , headers = { } ;
104
- browser . xhr ( 'METHOD ' , 'URL' , 'POST' , function ( c , r ) {
104
+ browser . xhr ( 'GET ' , 'URL' , 'POST' , function ( c , r ) {
105
105
code = c ;
106
106
response = r ;
107
107
} , { 'X-header' : 'value' } ) ;
108
108
109
- expect ( xhr . method ) . toEqual ( 'METHOD ' ) ;
109
+ expect ( xhr . method ) . toEqual ( 'GET ' ) ;
110
110
expect ( xhr . url ) . toEqual ( 'URL' ) ;
111
111
expect ( xhr . post ) . toEqual ( 'POST' ) ;
112
112
expect ( xhr . headers ) . toEqual ( {
113
- "Content-Type" : "application/x-www-form-urlencoded" ,
114
113
"Accept" : "application/json, text/plain, */*" ,
115
114
"X-Requested-With" : "XMLHttpRequest" ,
116
115
"X-header" :"value"
@@ -124,9 +123,27 @@ describe('browser', function(){
124
123
expect ( code ) . toEqual ( 202 ) ;
125
124
expect ( response ) . toEqual ( 'RESPONSE' ) ;
126
125
} ) ;
126
+
127
+ it ( 'should not set Content-type header for GET requests' , function ( ) {
128
+ browser . xhr ( 'GET' , 'URL' , 'POST-DATA' , function ( c , r ) { } ) ;
127
129
128
- } ) ;
130
+ expect ( xhr . headers [ 'Content-Type' ] ) . not . toBeDefined ( ) ;
131
+ } ) ;
132
+
133
+ it ( 'should set Content-type header for POST requests' , function ( ) {
134
+ browser . xhr ( 'POST' , 'URL' , 'POST-DATA' , function ( c , r ) { } ) ;
135
+
136
+ expect ( xhr . headers [ 'Content-Type' ] ) . toBeDefined ( ) ;
137
+ expect ( xhr . headers [ 'Content-Type' ] ) . toEqual ( 'application/x-www-form-urlencoded' ) ;
138
+ } ) ;
139
+
140
+ it ( 'should set default headers for custom methods' , function ( ) {
141
+ browser . xhr ( 'CUSTOM' , 'URL' , 'POST-DATA' , function ( c , r ) { } ) ;
129
142
143
+ expect ( xhr . headers [ 'Accept' ] ) . toEqual ( 'application/json, text/plain, */*' ) ;
144
+ expect ( xhr . headers [ 'X-Requested-With' ] ) . toEqual ( 'XMLHttpRequest' ) ;
145
+ } ) ;
146
+ } ) ;
130
147
131
148
describe ( 'defer' , function ( ) {
132
149
it ( 'should execute fn asynchroniously via setTimeout' , function ( ) {
0 commit comments