From bf07a0f6062e858207f395615d452e3e84ac82fa Mon Sep 17 00:00:00 2001 From: Nathan Cahill Date: Thu, 1 Jul 2021 14:52:27 +0200 Subject: [PATCH] support headers in xmlhttprequest --- src/utils/faker.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/faker.js b/src/utils/faker.js index 003bf6d..1cf2544 100644 --- a/src/utils/faker.js +++ b/src/utils/faker.js @@ -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() { @@ -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();