DefinitelyTyped/fetch-mock/fetch-mock-tests.ts
2016-07-06 02:47:02 +02:00

35 lines
774 B
TypeScript

/// <reference path="./fetch-mock.d.ts" />
import * as fetchMock from "fetch-mock";
fetchMock.mock("http://test.com", 200);
fetchMock.mock(/test\.com/, 200);
fetchMock.mock(() => true, 200);
fetchMock.mock((url, opts) => true, 200);
fetchMock.mock(/test/, "test").mock(/test/, { a: "b" });
fetchMock.mock(/test/, {
status: 200,
headers: {
"test": "test"
},
body: {
a: "b"
}
});
fetchMock.reMock();
fetchMock.restore().reset();
fetchMock.calls().matched[0][1].body;
fetchMock.calls().unmatched[0][0].toUpperCase();
fetchMock.calls("http://test.com")[0][0].toUpperCase();
fetchMock.calls("http://test.com")[0][1].body;
fetchMock.called("http://test.com");
fetchMock.lastCall()[1].body;
fetchMock.lastUrl();
fetchMock.lastOptions();