Skip to content

Commit db00a75

Browse files
committed
add test case for arraybuffer responseType
1 parent 4eb5409 commit db00a75

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/index.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,31 @@ function describeXHRProps() {
413413
});
414414

415415
describe('#responseType', function () {
416+
417+
it('supports binary data (arraybuffer responseType)', function (done) {
418+
419+
var responseData = new Buffer(909);
420+
421+
var binaryScope = nock('http://example.com')
422+
.get('/music.mp3')
423+
.reply(200, responseData, {
424+
'Content-Type': 'audio/mpeg'
425+
});
426+
427+
req.responseType = 'arraybuffer';
428+
req.open('GET', 'http://example.com/music.mp3');
429+
req.send();
430+
431+
req.onload = function () {
432+
433+
assume(req.responseType).equals('arraybuffer');
434+
assume(req.response).equals(responseData.buffer);
435+
436+
binaryScope.done();
437+
done();
438+
};
439+
});
440+
416441
it('intially is `\'\'`', function () {
417442
assume(req.responseType).equals('');
418443
});

0 commit comments

Comments
 (0)