Skip to content

Commit ae225db

Browse files
committed
support headers in xmlhttprequest
1 parent ca636db commit ae225db

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/utils/faker.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable no-restricted-globals */
22
import { newMockXhr } from 'mock-xmlhttprequest';
33
import responseBuilder from './responseBuilder';
4+
import statusTextMap from './statusMap';
45

56
class Faker {
67
constructor() {
@@ -72,7 +73,8 @@ class Faker {
7273
const { method, url } = xhr;
7374
const matched = this.matchMock(url, method);
7475
if (matched) {
75-
xhr.respond(matched.status || 200, {}, matched.response);
76+
const status = matched.status || 200
77+
xhr.respond(status, matched.headers, matched.response, statusTextMap[status]);
7678
} else {
7779
// eslint-disable-next-line new-cap
7880
const realXhr = new self.realXMLHttpRequest();

0 commit comments

Comments
 (0)