@crowdin/app-project-module
Version:
Module that generates for you all common endpoints for serving standalone Crowdin App
74 lines (73 loc) • 4.2 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runProjectIntegrationTests = exports.mockDirectories = exports.mockFiles = exports.mockStoragesById = exports.mockProjectId = void 0;
const globals_1 = require("@jest/globals");
const mock_axios_1 = require("./mocks/mock-axios");
const mock_crowdin_api_client_1 = require("./mocks/mock-crowdin-api-client");
const get_integration_files_1 = require("./get-integration-files");
const update_crowdin_1 = require("./update-crowdin");
const update_integration_1 = require("./update-integration");
// CommonData
exports.mockProjectId = 1;
exports.mockStoragesById = {};
exports.mockFiles = [];
exports.mockDirectories = [];
jest.mock('axios', () => mock_axios_1.mockAxios);
jest.mock('@crowdin/crowdin-api-client', () => jest.fn().mockImplementation(() => mock_crowdin_api_client_1.mockCrowdinApiClient));
const runProjectIntegrationTests = ({ getAppConfig, integrationTestConfig, }) => {
(0, globals_1.describe)('Run integration module tests', () => {
var _a, _b, _c;
if (!((_a = integrationTestConfig.getIntegrationFiles) === null || _a === void 0 ? void 0 : _a.expected.length)) {
throw new Error('Please provide a valid expected files');
}
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
if (integrationTestConfig === null || integrationTestConfig === void 0 ? void 0 : integrationTestConfig.beforeAll) {
yield integrationTestConfig.beforeAll();
}
}));
(0, globals_1.test)('getIntegrationFiles()', () => __awaiter(void 0, void 0, void 0, function* () {
var _d;
if ((_d = integrationTestConfig.getIntegrationFiles) === null || _d === void 0 ? void 0 : _d.setup) {
yield integrationTestConfig.getIntegrationFiles.setup();
}
const appConfig = yield getAppConfig();
yield (0, get_integration_files_1.getIntegrationFilesTest)({ appConfig, integrationTestConfig });
}));
if (!((_b = integrationTestConfig.updateCrowdin) === null || _b === void 0 ? void 0 : _b.disabled)) {
(0, globals_1.test)('updateCrowdin()', () => __awaiter(void 0, void 0, void 0, function* () {
var _e;
if ((_e = integrationTestConfig.updateCrowdin) === null || _e === void 0 ? void 0 : _e.setup) {
yield integrationTestConfig.updateCrowdin.setup();
}
const appConfig = yield getAppConfig();
yield (0, update_crowdin_1.updateCrowdinTest)({
appConfig,
integrationTestConfig,
});
}));
}
if (!((_c = integrationTestConfig.updateIntegration) === null || _c === void 0 ? void 0 : _c.disabled)) {
(0, globals_1.test)('updateIntegration()', () => __awaiter(void 0, void 0, void 0, function* () {
var _f;
if ((_f = integrationTestConfig.updateIntegration) === null || _f === void 0 ? void 0 : _f.setup) {
yield integrationTestConfig.updateIntegration.setup();
}
const appConfig = yield getAppConfig();
yield (0, update_integration_1.updateIntegrationTest)({
appConfig,
integrationTestConfig,
});
}));
}
});
};
exports.runProjectIntegrationTests = runProjectIntegrationTests;