(api, responses)
| 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 = {}) { |
no test coverage detected