@bitloops/bl-transpiler
Version:
The one and only Bitloops Language transpiler
71 lines • 3.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/**
* Bitloops Language CLI
* Copyright (C) 2022 Bitloops S.A.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* For further information you can contact legal(at)bitloops.com.
*/
const mappings_js_1 = require("../../src/helpers/mappings.js");
const Transpiler_js_1 = tslib_1.__importDefault(require("../../src/Transpiler.js"));
const index_js_1 = require("../../src/index.js");
const supportedLanguages_js_1 = require("../../src/target/supportedLanguages.js");
const codeFormatting_js_1 = require("../../src/target/typescript-nest/core/codeFormatting.js");
const index_js_2 = require("./mocks/entity-primitives/index.js");
describe('Valid fromPrimitives & toPrimitives End To End', () => {
const boundedContext = 'Hello world';
const module = 'demo';
const fileId = 'fileName';
const options = {
formatterConfig: null,
targetLanguage: supportedLanguages_js_1.SupportedLanguages.TypeScriptNest,
};
let targetCode;
index_js_2.ENTITY_PRIMITIVES_END_TO_END_TEST_CASES.forEach((testCase) => {
it(`${testCase.description}`, () => {
// given
const input = {
core: [
{
boundedContext,
module,
fileId,
fileContents: testCase.input,
},
],
setup: [],
};
// when
const result = index_js_1.transpiler.transpile(input, options);
if (!Transpiler_js_1.default.isTranspileError(result)) {
targetCode = result;
}
else {
throw new Error('Transpile error');
}
// then
const formattedOutput = (0, codeFormatting_js_1.formatString)(testCase.output, options.formatterConfig);
const entityOutput = targetCode.core.find((item) => item.classType === mappings_js_1.ClassTypes.RootEntity);
expect(entityOutput).toBeDefined();
if (!entityOutput) {
throw new Error('Entity output not found');
}
expect(entityOutput.fileContent).toEqual(formattedOutput);
});
});
});
//# sourceMappingURL=entity-primitives.steps.js.map