component-dbs-core
Version:
DTO objects shared among device backend
57 lines • 3.25 kB
JavaScript
"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 transactionService_1 = require("../transactions/transactionService");
const _1 = require(".");
const depositService_1 = require("../deposits/depositService");
const deviceService_1 = require("../devices/deviceService");
jest.mock('../devices/deviceService');
jest.mock('../devices/deviceVerification');
jest.mock('../transactions/transactionService');
jest.mock('../deposits/depositService');
describe('deviceTableStream lambda test suite', () => {
beforeEach(() => {
transactionService_1.TransactionService.onTransactionStream.mockReset();
depositService_1.DepositService.onDepositStream.mockReset();
deviceService_1.DeviceService.mockOnDeviceSettingsStream.mockReset();
});
it('should be able to handle stream with different records', (done) => __awaiter(void 0, void 0, void 0, function* () {
_1.onDeviceTableStreamHandler({
args: { id: '123' },
Records: [
{ dynamodb: { Keys: { type: { S: 'transaction.1239120312093' } } } },
{ dynamodb: { Keys: { type: { S: 'transaction.1239120312093' } } } },
{ dynamodb: { Keys: { type: { S: 'transaction.1239120312093' } } } },
{ dynamodb: { Keys: { type: { S: 'deposit.1239120312093' } } } },
{ dynamodb: { Keys: { type: { S: 'settings' } } } },
{ dynamodb: { Keys: { type: { S: 'core' } } } },
],
request: { headers: { authorization: 'token001' } },
}, {}, () => {
expect(transactionService_1.TransactionService.onTransactionStream).toHaveBeenCalledTimes(1);
expect(depositService_1.DepositService.onDepositStream).toHaveBeenCalledTimes(1);
expect(deviceService_1.DeviceService.mockOnDeviceSettingsStream).toHaveBeenCalledTimes(1);
done();
});
}));
it('should be able to handle other stream', (done) => __awaiter(void 0, void 0, void 0, function* () {
_1.onDeviceTableStreamHandler({
args: { id: '123' },
Records: [{ dynamodb: { Keys: { type: { S: 'core' } } } }],
request: { headers: { authorization: 'token001' } },
}, {}, () => {
expect(depositService_1.DepositService.onDepositStream).toHaveBeenCalledTimes(0);
expect(transactionService_1.TransactionService.onTransactionStream).toHaveBeenCalledTimes(0);
done();
});
}));
});
//# sourceMappingURL=deviceTableStreamHandler.spec.js.map