Merge pull request #18655 from chrissinclair/master

[fetch-mock] Added missing flush() method to FetchMockStatic
This commit is contained in:
Andrew Casey
2017-08-07 18:11:18 -07:00
committed by GitHub
2 changed files with 15 additions and 2 deletions
+4
View File
@@ -1,4 +1,5 @@
import * as fetchMock from "fetch-mock";
import { MockResponse } from "fetch-mock";
fetchMock.mock("http://test.com", 200);
fetchMock.mock(/test\.com/, 200);
@@ -65,3 +66,6 @@ const myMatcher: fetchMock.MockMatcherFunction = (
url: string,
opts: fetchMock.MockRequest
) => true;
fetchMock.flush().then(resolved => resolved.forEach(console.log));
fetchMock.flush().catch(r => r);
+11 -2
View File
@@ -1,6 +1,9 @@
// Type definitions for fetch-mock 5.8
// Type definitions for fetch-mock 5.12
// Project: https://github.com/wheresrhys/fetch-mock
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>, Tamir Duberstein <https://github.com/tamird>, Risto Keravuori <https://github.com/merrywhether>
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
// Tamir Duberstein <https://github.com/tamird>
// Risto Keravuori <https://github.com/merrywhether>
// Chris Sinclair <https://github.com/chrissinclair>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -333,6 +336,12 @@ declare namespace fetchMock {
*/
reset(): this;
/**
* Returns a promise that resolves once all fetches handled by fetch-mock
* have resolved.
*/
flush(): Promise<MockResponse[]>;
/**
* Returns all calls to fetch, grouped by whether fetch-mock matched
* them or not.