component-dbs-core
Version:
DTO objects shared among device backend
46 lines • 2.65 kB
JavaScript
;
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 ts_mockito_1 = require("ts-mockito");
const dynamodbService_1 = require("./dynamodbService");
const config_1 = require("../config");
const dynamodbUtils_1 = require("./dynamodbUtils");
describe('dynamodb service test suite', () => {
const mockEnvService = ts_mockito_1.mock(config_1.EnvironmentService);
const mockUtils = ts_mockito_1.mock(dynamodbUtils_1.DynamodbUtils);
it('should be able to create dynamodb document client', () => {
const dynamodbService = new dynamodbService_1.DynamodbService(ts_mockito_1.instance(mockEnvService), ts_mockito_1.instance(mockUtils));
expect(dynamodbService).not.toBe(null);
});
it('should be able to return result in getQueryOutput', () => __awaiter(void 0, void 0, void 0, function* () {
const dynamodbService = new dynamodbService_1.DynamodbService(ts_mockito_1.instance(mockEnvService), ts_mockito_1.instance(mockUtils));
dynamodbService.utils = ts_mockito_1.instance(mockUtils);
dynamodbService.documentClient = new MockDocumentClient();
ts_mockito_1.when(mockUtils.prepareMultiQueryParams(ts_mockito_1.anything(), ts_mockito_1.anything(), ts_mockito_1.anything(), ts_mockito_1.anything())).thenReturn({});
const rest = yield dynamodbService.getQueryOutput({}, '', '', '');
console.log(rest);
expect(rest).toMatchObject([]);
}));
it('should be able to wrap xray on dyanmodb client', () => {
ts_mockito_1.when(mockEnvService.isInLambda).thenReturn(true);
const dynamodbService = new dynamodbService_1.DynamodbService(ts_mockito_1.instance(mockEnvService), ts_mockito_1.instance(mockUtils));
expect(dynamodbService).not.toBe(null);
});
});
class MockDocumentClient {
query() {
return this;
}
promise() {
return Promise.resolve([]);
}
}
//# sourceMappingURL=dynamodbService.spec.js.map