UNPKG

@universis/candidates

Version:

Universis api server plugin for study program candidates, internship selection etc

66 lines (57 loc) 2.73 kB
"use strict";var _app = _interopRequireDefault(require("@universis/api/dist/server/app")); var _express = require("@themost/express"); var _data = require("@themost/data"); var _CandidateService = require("./CandidateService");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {Promise.resolve(value).then(_next, _throw);}}function _asyncToGenerator(fn) {return function () {var self = this,args = arguments;return new Promise(function (resolve, reject) {var gen = fn.apply(self, args);function _next(value) {asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);}function _throw(err) {asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);}_next(undefined);});};} describe('UniversisCandidateService', () => { /** * @type {ExpressDataApplication} */ let application; // noinspection JSValidateJSDoc /** * @type {ExpressDataContext} */ let context; beforeAll(() => { /** * @type {ExpressDataApplication} */ application = _app.default.get(_express.ExpressDataApplication.name); }); beforeEach( /*#__PURE__*/_asyncToGenerator(function* () { context = application.createContext(); })); afterEach(done => { // important: clear cache after each test const configuration = context.getConfiguration(); if (configuration.hasOwnProperty('cache')) { delete configuration.cache; } context.finalize(() => { return done(); }); }); it('should create instance', () => { const service = new _CandidateService.CandidateService(application); expect(service).toBeTruthy(); }); it('should install service', () => { /** * @type {DataConfigurationStrategy} */ const dataConfiguration = application.getConfiguration().getStrategy(_data.DataConfigurationStrategy); // validate service expect(application.getService(_CandidateService.CandidateService)).toBeFalsy(); // expect UserLoginAction to be undefined let model = dataConfiguration.getModelDefinition('StudyProgramRegisterAction'); expect(model).toBeTruthy(); // use service application.useService(_CandidateService.CandidateService); //validate service instance expect(application.getService(_CandidateService.CandidateService)).toBeTruthy(); // validate model definition model = dataConfiguration.getModelDefinition('StudyProgramRegisterAction'); expect(model).toBeTruthy(); }); }); //# sourceMappingURL=CandidateService.spec.js.map