Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
de-type body to allow use of ArrayBuffer, Blob or something else
- Loading branch information
James Newell
committed
Feb 20, 2018
1 parent
3d9df5c
commit a7c6250
Showing
10 changed files
with
236 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
printWidth: 120, | ||
singleQuote: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {expect} from 'chai'; | ||
import mock from 'xhr-mock'; | ||
|
||
describe('native', () => { | ||
beforeEach(() => mock.setup()); | ||
afterEach(() => mock.teardown()); | ||
|
||
it('should get a blob', done => { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
mock.get('/myfile.png', { | ||
body: new ArrayBuffer(0) | ||
}); | ||
|
||
// sourced from https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data | ||
const req = new XMLHttpRequest(); | ||
req.open('GET', '/myfile.png', true); | ||
req.responseType = 'arraybuffer'; | ||
|
||
req.onload = function(oEvent) { | ||
const arrayBuffer = req.response; // Note: not oReq.responseText | ||
expect(arrayBuffer).to.be.an('ArrayBuffer'); | ||
done(); | ||
}; | ||
|
||
req.send(null); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
this should read
arraybuffer
instead ofblob