Skip to content

Commit

Permalink
support headers in xmlhttprequest
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancahill committed Jul 1, 2021
1 parent ca636db commit ae225db
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils/faker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-restricted-globals */
import { newMockXhr } from 'mock-xmlhttprequest';
import responseBuilder from './responseBuilder';
import statusTextMap from './statusMap';

class Faker {
constructor() {
Expand Down Expand Up @@ -72,7 +73,8 @@ class Faker {
const { method, url } = xhr;
const matched = this.matchMock(url, method);
if (matched) {
xhr.respond(matched.status || 200, {}, matched.response);
const status = matched.status || 200
xhr.respond(status, matched.headers, matched.response, statusTextMap[status]);
} else {
// eslint-disable-next-line new-cap
const realXhr = new self.realXMLHttpRequest();
Expand Down

0 comments on commit ae225db

Please sign in to comment.