UNPKG

@crowdin/app-project-module

Version:

Module that generates for you all common endpoints for serving standalone Crowdin App

18 lines (17 loc) 865 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mockAxios = void 0; const index_1 = require("../index"); const mockOriginalAxios = jest.requireActual('axios'); const mock = Object.assign(Object.assign({}, mockOriginalAxios), { get: jest.fn((url) => { expect(url).toMatch(/^file-id:(\d+)$/); const fileId = Number(url.replace('file-id:', '')); const file = index_1.mockFiles.find(({ id }) => id === fileId); const storageId = file === null || file === void 0 ? void 0 : file.storageId; expect(storageId).not.toBeUndefined(); return { // @ts-ignore data: index_1.mockStoragesById[storageId].data, }; }) }); exports.mockAxios = Object.assign(Object.assign({}, mock), { default: Object.assign({ create: () => (Object.assign({}, mock)) }, mock) });