diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 4c8f22a6f4..bc657ef79b 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Sinon 4.0 +// Type definitions for Sinon 4.1 // Project: http://sinonjs.org/ // Definitions by: William Sears // Jonathan Little @@ -11,10 +11,8 @@ // sinon uses DOM dependencies which are absent in browser-less environment like node.js // to avoid compiler errors this monkey patch is used // see more details in https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11351 -// tslint:disable no-empty-interface -interface Event { } -interface Document { } -// tslint:enable no-empty-interface +interface Event { } // tslint:disable-line no-empty-interface +interface Document { } // tslint:disable-line no-empty-interface declare namespace Sinon { interface SinonSpyCallApi { @@ -293,14 +291,10 @@ declare namespace Sinon { FakeXMLHttpRequest: SinonFakeXMLHttpRequest; } - interface SinonFakeServer { + interface SinonFakeServer extends SinonFakeServerOptions { // Properties - autoRespond: boolean; - autoRespondAfter: number; - fakeHTTPMethods: boolean; getHTTPMethod(request: SinonFakeXMLHttpRequest): string; requests: SinonFakeXMLHttpRequest[]; - respondImmediately: boolean; // Methods respondWith(body: string): void; @@ -322,8 +316,15 @@ declare namespace Sinon { restore(): void; } + interface SinonFakeServerOptions { + autoRespond?: boolean; + autoRespondAfter?: number; + fakeHTTPMethods?: boolean; + respondImmediately?: boolean; + } + interface SinonFakeServerStatic { - create(): SinonFakeServer; + create(options?: SinonFakeServerOptions): SinonFakeServer; } interface SinonStatic { diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 33ac93f595..1fafb259ee 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -230,6 +230,15 @@ function testSpy() { sinon.spy().calledImmediatelyBefore(otherSpy); } +function testFakeServer() { + sinon.fakeServer.create({ + autoRespond: true, + autoRespondAfter: 3, + fakeHTTPMethods: true, + respondImmediately: false + }); +} + testOne(); testTwo(); testThree(); @@ -249,6 +258,7 @@ testGetterStub(); testSetterStub(); testValueStub(); testThrowsStub(); +testFakeServer(); const clock = sinon.useFakeTimers(); clock.setSystemTime(1000);