Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: reply can't replay with ArrayBuffer, Blob, etc. responses #66

Merged
merged 1 commit into from
Aug 1, 2017
Merged

Feature Request: reply can't replay with ArrayBuffer, Blob, etc. responses #66

merged 1 commit into from
Aug 1, 2017

Conversation

petraszd
Copy link
Contributor

Problem

Let's say I have code like:

var buffer = new ArrayBuffer(1);
var view = new Uint8Array(buffer);
view[0] = 0xAA;

mock.onGet('/some-url').reply(200, buffer);
axios({
  url: '/some-url',
  method: 'GET',
  responseType: 'arraybuffer'
}).then(function(response) {
  response.data;  // <-- HERE response.data is not a ArrayBuffer, but an empty object `{}`
});

So, I can't mock for example image generator.

Solution

I've changed a check isObject to be way more stricter thus allowing blobs, buffers, files to no be wrapped and unwrapped with JSON converter.

Notes

I've created a test, but I've not updated documentation since my English is quite bad.

It also allows to mock other non simple object (like Blob) responses.
@ctimmerm ctimmerm merged commit 817ccd0 into ctimmerm:master Aug 1, 2017
@ctimmerm
Copy link
Owner

ctimmerm commented Aug 1, 2017

Thanks!

@k4tan
Copy link

k4tan commented Sep 21, 2017

Hi there,

Any plans to release a package with this functionality?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants