@cuba-platform/front-generator
Version:
CUBA Platform front-end clients generator
34 lines • 2.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const cuba_model_utils_1 = require("../../../common/model/cuba-model-utils");
const chai_1 = require("chai");
const projectModel = require('../../fixtures/mpg-projectModel.json');
describe('cuba model utils', function () {
it('should find view', function () {
(0, chai_1.expect)((0, cuba_model_utils_1.findView)(projectModel, { entityName: '', name: '' })).to.be.undefined;
(0, chai_1.expect)((0, cuba_model_utils_1.findView)(projectModel, { entityName: 'MpgUserInfo', name: '_minimal' }).classFqn)
.eq('com.company.mpg.entity.MpgUserInfo');
});
it('should find query', function () {
(0, chai_1.expect)((0, cuba_model_utils_1.findQuery)(projectModel, { entityName: '', name: '' })).to.be.undefined;
(0, chai_1.expect)((0, cuba_model_utils_1.findQuery)(projectModel, { entityName: 'mpg$Car', name: 'allCars' }).jpql).eq('select c from mpg$Car c');
});
it('should find service method', function () {
(0, chai_1.expect)((0, cuba_model_utils_1.findServiceMethod)(projectModel, { methodName: '', serviceName: '' })).to.be.null;
const methodInfo = { methodName: 'addFavorite', serviceName: 'mpg_FavoriteService' };
const methodModel = (0, cuba_model_utils_1.findServiceMethod)(projectModel, methodInfo);
(0, chai_1.expect)(methodModel.service.name).eq('mpg_FavoriteService');
(0, chai_1.expect)(methodModel.method.name).eq('addFavorite');
});
it('should find entity', function () {
(0, chai_1.expect)((0, cuba_model_utils_1.findEntity)(projectModel, { name: '' })).to.be.undefined;
(0, chai_1.expect)((0, cuba_model_utils_1.findEntity)(projectModel, { name: 'mpg$Car' }).fqn).eq('com.company.mpg.entity.Car');
(0, chai_1.expect)((0, cuba_model_utils_1.findEntity)(projectModel, { name: 'sec$User' }).fqn).eq('com.haulmont.cuba.security.entity.User');
});
it('should collect attributes from hierarchy', function () {
const secUser = (0, cuba_model_utils_1.findEntity)(projectModel, { name: 'sec$User' });
const attrs = (0, cuba_model_utils_1.collectAttributesFromHierarchy)(secUser, projectModel);
(0, chai_1.expect)(attrs.find(a => a.name == 'version')).is.not.empty;
});
});
//# sourceMappingURL=cuba-model-utils.test.js.map