@@ -12,6 +12,10 @@ global.window.XMLHttpRequest = function() {
12
12
this . send = noop ;
13
13
} ;
14
14
15
+ global . window . FormData = function ( ) { } ;
16
+ global . window . Blob = function ( ) { } ;
17
+ global . window . ArrayBuffer = function ( ) { } ;
18
+
15
19
var test = require ( 'tape' ) . test ;
16
20
var http = require ( '../index.js' ) ;
17
21
@@ -86,3 +90,26 @@ test('Test withCredentials param', function(t) {
86
90
87
91
t . end ( ) ;
88
92
} ) ;
93
+
94
+ test ( 'Test POST XHR2 types' , function ( t ) {
95
+ t . plan ( 3 ) ;
96
+ var url = '/api/foo' ;
97
+
98
+ var request = http . request ( { url : url , method : 'POST' } , noop ) ;
99
+ request . xhr . send = function ( data ) {
100
+ t . ok ( data instanceof global . window . ArrayBuffer , 'data should be instanceof ArrayBuffer' ) ;
101
+ } ;
102
+ request . end ( new global . window . ArrayBuffer ( ) ) ;
103
+
104
+ request = http . request ( { url : url , method : 'POST' } , noop ) ;
105
+ request . xhr . send = function ( data ) {
106
+ t . ok ( data instanceof global . window . Blob , 'data should be instanceof Blob' ) ;
107
+ } ;
108
+ request . end ( new global . window . Blob ( ) ) ;
109
+
110
+ request = http . request ( { url : url , method : 'POST' } , noop ) ;
111
+ request . xhr . send = function ( data ) {
112
+ t . ok ( data instanceof global . window . FormData , 'data should be instanceof FormData' ) ;
113
+ } ;
114
+ request . end ( new global . window . FormData ( ) ) ;
115
+ } ) ;
0 commit comments