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

Function mockAPI

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

Source from the content-addressed store, hash-verified

10 });
11
12 function mockAPI(api, responses) {
13 api.request = jest.fn().mockImplementation((path, options = {}) => {
14 const normalizedPath = path.indexOf('?') !== -1 ? path.slice(0, path.indexOf('?')) : path;
15 const response = responses[normalizedPath];
16 return typeof response === 'function'
17 ? Promise.resolve(response(options))
18 : Promise.reject(new Error(`No response for path '${normalizedPath}'`));
19 });
20 }
21
22 describe('editorialWorkflowGit', () => {
23 it('should create PR with correct base branch name when publishing with editorial workflow', () => {

Callers 1

API.spec.jsFile · 0.70

Calls 1

fnMethod · 0.80

Tested by

no test coverage detected