UNPKG

@cuba-platform/front-generator

Version:
42 lines 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const questions_1 = require("../../common/questions"); const projectModel = require("../fixtures/mpg-projectModel.json"); const chai_1 = require("chai"); describe('interactive CLI question helpers', () => { it('correctly creates choices for an Entity', () => { const prop = { code: 'test', caption: 'test', propertyType: "ENTITY" /* ENTITY */, }; // @ts-ignore TODO VP Replace enums with string union types in ProjectModel https://github.com/cuba-platform/front-generator/issues/46 const question = (0, questions_1.fromStudioProperty)(prop, projectModel); (0, chai_1.expect)(question.choices).to.exist; (0, chai_1.expect)(question.choices).to.be.an('Array'); const expectedEntityNames = ["MpgUserInfo", "mpg$SparePart", "mpg$Car", "mpg$FavoriteCar", "mpg$TechnicalCertificate", "mpg$Garage", "mpg$CarRent"]; const actualEntityNames = question.choices.map((choice) => choice.name); (0, chai_1.expect)(actualEntityNames).to.deep.equal(expectedEntityNames); }); it('correctly creates choices for a View', () => { const prop = { code: 'test', caption: 'test', propertyType: "VIEW" /* VIEW */, }; const previousAnswers = { entity: { name: 'mpg$FavoriteCar' } }; // @ts-ignore TODO VP Replace enums with string union types in ProjectModel https://github.com/cuba-platform/front-generator/issues/46 const question = (0, questions_1.fromStudioProperty)(prop, projectModel); (0, chai_1.expect)(question.choices).to.exist; (0, chai_1.expect)(question.choices).to.be.a('Function'); const expectedViewNames = ["_minimal", "_local", "_base", "favoriteCar-view", "favoriteCar-edit"]; const actualViewNames = question.choices(previousAnswers).map((choice) => choice.name); (0, chai_1.expect)(actualViewNames).to.deep.equal(expectedViewNames); }); }); //# sourceMappingURL=questions.test.js.map