@@ -59,3 +59,55 @@ QUnit.asyncTest("GET requests with dataType parse JSON (#106)", function(){
59
59
start ( ) ;
60
60
} ) ;
61
61
} ) ;
62
+
63
+ QUnit . asyncTest ( "ignores case of type parameter for a post request (#100)" , function ( ) {
64
+ var oldXhr = window . XMLHttpRequest || window . ActiveXObject ,
65
+ requestHeaders = {
66
+ CONTENT_TYPE : "Content-Type"
67
+ } ,
68
+ xhrFixture = function ( ) {
69
+ this . open = function ( type , url ) {
70
+ } ;
71
+
72
+ this . send = function ( ) {
73
+ this . readyState = 4 ;
74
+ this . status = 200 ;
75
+ this . onreadystatechange ( ) ;
76
+ } ;
77
+
78
+ this . setRequestHeader = function ( header , value ) {
79
+ if ( header === requestHeaders . CONTENT_TYPE ) {
80
+ var o = { } ;
81
+ o [ header ] = value ;
82
+ this . responseText = JSON . stringify ( o ) ;
83
+ }
84
+ } ;
85
+ } ;
86
+
87
+ // replace with fixture
88
+ if ( window . XMLHttpRequest ) {
89
+ window . XMLHttpRequest = xhrFixture ;
90
+ } else if ( window . ActiveXObject ) {
91
+ window . ActiveXObject = xhrFixture ;
92
+ }
93
+
94
+ ajax ( {
95
+ type : "post" ,
96
+ url : "/foo" ,
97
+ data : {
98
+ bar : "qux"
99
+ }
100
+ } ) . then ( function ( value ) {
101
+ QUnit . equal ( value [ requestHeaders . CONTENT_TYPE ] , "application/x-www-form-urlencoded" ) ;
102
+ } , function ( reason ) {
103
+ QUnit . notOk ( reason , "request failed with reason = " , reason ) ;
104
+ } ) . then ( function ( ) {
105
+ // restore original values
106
+ if ( window . XMLHttpRequest ) {
107
+ window . XMLHttpRequest = oldXhr ;
108
+ } else if ( window . ActiveXObject ) {
109
+ window . ActiveXObject = oldXhr ;
110
+ }
111
+ start ( ) ;
112
+ } ) ;
113
+ } ) ;
0 commit comments