UNPKG

component-dbs-core

Version:

DTO objects shared among device backend

53 lines 3.02 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 depositService_1 = require("../deposits/depositService"); const devices_1 = require("../devices"); const lambdaDeposit_1 = require("./lambdaDeposit"); jest.mock('../devices/deviceService'); jest.mock('../devices/deviceVerification'); jest.mock('../deposits/depositService'); describe('deposit lambda test suite', () => { beforeEach(() => { depositService_1.DepositService.getDeposits.mockReset(); depositService_1.DepositService.getDeposit.mockReset(); depositService_1.DepositService.onDepositUpdate.mockReset(); devices_1.DeviceVerification.mockCheckAccessToken.mockReset(); devices_1.DeviceVerification.accessTokenValid = true; }); it('should be able to handle getDeposits request', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaDeposit_1.getDepositsHandler({ request: { headers: { authorization: 'token001' } }, args: {} }, {}, (error, response) => { expect(depositService_1.DepositService.getDeposits).toHaveBeenCalledTimes(1); expect(devices_1.DeviceVerification.mockCheckAccessToken).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to handle getDeposit request', (done) => __awaiter(void 0, void 0, void 0, function* () { lambdaDeposit_1.getDepositHandler({ request: { headers: { authorization: 'token001' } }, args: { depositUuid: "id" } }, {}, (error, response) => { expect(depositService_1.DepositService.getDeposit).toHaveBeenCalledTimes(1); expect(devices_1.DeviceVerification.mockCheckAccessToken).toHaveBeenCalledTimes(1); done(); }); })); it('should be able to handle onDepositUpdate request', (done) => __awaiter(void 0, void 0, void 0, function* () { devices_1.DeviceService.mockGetDeviceStatus = jest .fn() .mockResolvedValue("ACTIVE" /* ACTIVE */); lambdaDeposit_1.onDepositUpdateHandler({ args: { id: '123' }, request: { headers: { authorization: 'token001' } }, }, {}, () => { expect(depositService_1.DepositService.onDepositUpdate).toHaveBeenCalledTimes(1); done(); }); })); }); //# sourceMappingURL=lambdaDeposit.spec.js.map