@@ -12,6 +12,10 @@ global.window.XMLHttpRequest = function() {
1212 this . send = noop ;
1313} ;
1414
15+ global . window . FormData = function ( ) { } ;
16+ global . window . Blob = function ( ) { } ;
17+ global . window . ArrayBuffer = function ( ) { } ;
18+
1519var test = require ( 'tape' ) . test ;
1620var http = require ( '../index.js' ) ;
1721
@@ -86,3 +90,26 @@ test('Test withCredentials param', function(t) {
8690
8791 t . end ( ) ;
8892} ) ;
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