From 38df6613ce7cd2a25c03cf7194136c0229bccfa6 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Tue, 29 May 2018 23:55:03 +0100 Subject: [PATCH] sinon: move incorrect xhr restore method (#26119) --- types/sinon/index.d.ts | 2 +- types/sinon/sinon-tests.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 4bdf3272ee..2922b5a2c7 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -271,7 +271,6 @@ declare namespace Sinon { getAllResponseHeaders(): any; // Methods - restore(): void; setResponseHeaders(headers: any): void; setResponseBody(body: string): void; respond(status: number, headers: any, body: string): void; @@ -285,6 +284,7 @@ declare namespace Sinon { useFilters: boolean; addFilter(filter: (method: string, url: string, async: boolean, username: string, password: string) => boolean): void; onCreate(xhr: SinonFakeXMLHttpRequest): void; + restore(): void; } interface SinonFakeServer extends SinonFakeServerOptions { diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 0a88a4eeba..55e6a7a0bc 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -40,6 +40,7 @@ function testSandbox() { const xhr = sb.useFakeXMLHttpRequest(); xhr.useFilters = true; + xhr.restore(); const server = sb.useFakeServer(); server.respondWith('foo'); @@ -98,7 +99,6 @@ function testXHR() { const headers = xhr.getAllResponseHeaders(); const header = xhr.getResponseHeader('foo'); - xhr.restore(); xhr.setResponseHeaders({ 'Content-Type': 'text/html' }); xhr.setResponseBody('foo'); xhr.respond(200, { 'Content-Type': 'foo' }, 'bar'); @@ -107,6 +107,7 @@ function testXHR() { sinon.FakeXMLHttpRequest.useFilters = true; sinon.FakeXMLHttpRequest.addFilter((method, url, async, user, pass) => true); sinon.FakeXMLHttpRequest.onCreate = (xhr) => {}; + sinon.FakeXMLHttpRequest.restore(); } function testClock() {