Skip to content

Commit

Permalink
Fix fetch enable/disable test to work in all browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
morsdyce committed Mar 3, 2017
1 parent 460424b commit 8c95b89
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions dist/xhook.js
Expand Up @@ -564,6 +564,11 @@ XHookHttpRequest = WINDOW[XMLHTTP] = function() {
if (xhr.upload) {
facade.upload = request.upload = EventEmitter();
}
facade.UNSENT = 0;
facade.OPENED = 1;
facade.HEADERS_RECEIVED = 2;
facade.LOADING = 3;
facade.DONE = 4;
return facade;
};

Expand Down
2 changes: 1 addition & 1 deletion dist/xhook.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/tests.js
Expand Up @@ -150,10 +150,10 @@ describe('xhook', function() {
it ('should replace native fetch when enable is called', function(){
xhook.disable();
expect(typeof window.fetch).to.equal('function');
expect(window.fetch.toString()).to.equal('function fetch() { [native code] }');
expect((/\{\s*\[native code\]\s*\}/).test(window.fetch.toString())).to.equal(true);
xhook.enable();
expect(typeof window.fetch).to.equal('function');
expect(window.fetch.toString()).not.to.equal('function fetch() { [native code] }');
expect((/\{\s*\[native code\]\s*\}/).test(window.fetch.toString())).to.equal(false);
});

});
Expand Down

0 comments on commit 8c95b89

Please sign in to comment.