MCPcopy Create free account
hub / github.com/decaporg/decap-cms / mockAPI

Function mockAPI

packages/decap-cms-backend-github/src/__tests__/API.spec.js:13–21  ·  view source on GitHub ↗
(api, responses)

Source from the content-addressed store, hash-verified

11 });
12
13 function mockAPI(api, responses) {
14 api.request = jest.fn().mockImplementation((path, options = {}) => {
15 const normalizedPath = path.indexOf('?') !== -1 ? path.slice(0, path.indexOf('?')) : path;
16 const response = responses[normalizedPath];
17 return typeof response === 'function'
18 ? Promise.resolve(response(options))
19 : Promise.reject(new Error(`No response for path '${normalizedPath}'`));
20 });
21 }
22
23 describe('notes issues', () => {
24 function notesIssue(number, key, extra = {}) {

Callers 1

API.spec.jsFile · 0.70

Calls 2

fnMethod · 0.80
resolveMethod · 0.80

Tested by

no test coverage detected