UNPKG

component-dbs-core

Version:

DTO objects shared among device backend

112 lines 5.99 kB
"use strict"; 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 }); const lambdaIdentity_1 = require("./lambdaIdentity"); const identityService_1 = require("../identity/service/identityService"); jest.mock('../devices/deviceService'); jest.mock('../devices/deviceVerification'); jest.mock('../identity/service/identityService'); describe('lambda identityService test suite', () => { it('should be able to call identityForgotPassword', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaIdentity_1.identityForgotPassword({ args: { input: {} } }, {}, (_, response) => { expect(identityService_1.IdentityService.identityForgotPassword).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to call identitySignUp', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaIdentity_1.identitySignUp({ args: { input: {} } }, {}, (_, response) => { expect(identityService_1.IdentityService.identitySignUp).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to call identityLogin', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaIdentity_1.identityLogin({ args: { input: {} } }, {}, (_, response) => { expect(identityService_1.IdentityService.identityLogin).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to call checkAccessToken', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaIdentity_1.checkAccessToken({ args: { input: {} } }, {}, (_, response) => { expect(identityService_1.IdentityService.checkAccessToken).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to call identityChangePassword', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaIdentity_1.identityChangePassword({ args: { input: { pasword: '' } }, identity: { sub: '' } }, {}, (_, response) => { expect(identityService_1.IdentityService.identityChangePassword).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to call identityPhoneVerify', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaIdentity_1.identityPhoneVerify({ args: { input: {} }, request: { headers: { authorization: 'accessToken' } }, }, {}, (_, response) => { expect(identityService_1.IdentityService.identityPhoneVerify).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to call identityPhoneRegister', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaIdentity_1.identityPhoneRegister({ args: { deviceUuid: '1234' }, request: { headers: { authorization: 'accessToken' } }, }, {}, (_, response) => { expect(identityService_1.IdentityService.identityPhoneRegister).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to call identitySetPin', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaIdentity_1.identitySetPin({ args: { deviceUuid: '1234' }, request: { headers: { authorization: 'accessToken' } }, }, {}, (_, response) => { expect(identityService_1.IdentityService.identitySetPin).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to call identityVerifyPin', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaIdentity_1.identityVerifyPin({ args: { deviceUuid: '1234' }, request: { headers: { authorization: 'accessToken' } }, }, {}, (_, response) => { expect(identityService_1.IdentityService.identityVerifyPin).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to call initiateForcedLogoff', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaIdentity_1.initiateForcedLogoff({ args: { deviceUuid: '1234', reason: 'Manually initiated' }, }, {}, (_, response) => { expect(identityService_1.IdentityService.initiateForcedLogoff).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to call identityForcedLogoff', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaIdentity_1.identityForcedLogoff({ args: { deviceUuid: '1234', reason: 'Manually initiated' }, }, {}, (_, response) => { expect(identityService_1.IdentityService.identityForcedLogoff).toHaveBeenCalledTimes(1); done(); }); })); it('should fail with empty deviceUuid', (done) => __awaiter(void 0, void 0, void 0, function* () { identityService_1.IdentityService.identityVerifyPin.mockReset(); lambdaIdentity_1.identityVerifyPin({ args: { deviceUuid: '' }, request: { headers: { authorization: 'accessToken' } }, }, {}, (error, response) => { expect(error).not.toBe(undefined); expect(identityService_1.IdentityService.identityVerifyPin).toHaveBeenCalledTimes(0); done(); }); })); }); //# sourceMappingURL=lambdaIdentity.spec.js.map