@@ -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
@@ -72,3 +76,26 @@ test('Test withCredentials param', function(t) {
7276
7377 t . end ( ) ;
7478} ) ;
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