@@ -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
@@ -72,3 +76,26 @@ test('Test withCredentials param', function(t) {
72
76
73
77
t . end ( ) ;
74
78
} ) ;
79
+
80
+ test ( 'Test POST XHR2 types' , function ( t ) {
81
+ t . plan ( 3 ) ;
82
+ var url = '/api/foo' ;
83
+
84
+ var request = http . request ( { url : url , method : 'POST' } , noop ) ;
85
+ request . xhr . send = function ( data ) {
86
+ t . ok ( data instanceof global . window . ArrayBuffer , 'data should be instanceof ArrayBuffer' ) ;
87
+ } ;
88
+ request . end ( new global . window . ArrayBuffer ( ) ) ;
89
+
90
+ request = http . request ( { url : url , method : 'POST' } , noop ) ;
91
+ request . xhr . send = function ( data ) {
92
+ t . ok ( data instanceof global . window . Blob , 'data should be instanceof Blob' ) ;
93
+ } ;
94
+ request . end ( new global . window . Blob ( ) ) ;
95
+
96
+ request = http . request ( { url : url , method : 'POST' } , noop ) ;
97
+ request . xhr . send = function ( data ) {
98
+ t . ok ( data instanceof global . window . FormData , 'data should be instanceof FormData' ) ;
99
+ } ;
100
+ request . end ( new global . window . FormData ( ) ) ;
101
+ } ) ;
0 commit comments