@microtica/mocks
Version:
Mock services for automated tests
65 lines • 3.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
// tslint:disable:no-console
const AWS = require("aws-sdk");
const DynamoDB = require("aws-sdk/clients/dynamodb");
const chai_1 = require("chai");
const __1 = require("../");
describe("Tests", () => {
it("should override endpoints and default region", () => {
const server = new __1.LocalStackDocker();
const LOCALHOST_URL = "http://localhost";
chai_1.assert.ok(AWS.config.apigateway.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.kinesis.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.dynamodb.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.dynamodbstreams.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.s3.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.firehose.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.lambda.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.sns.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.sqs.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.redshift.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.es.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.ses.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.route53.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.cloudformation.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.cloudwatch.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.ssm.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.ok(AWS.config.secretsmanager.endpoint.startsWith(LOCALHOST_URL));
chai_1.assert.equal(AWS.config.region, "eu-central-1");
});
it("Should be able to launch localstack docker", async () => {
try {
const server = new __1.LocalStackDocker();
await server.start();
const client = new DynamoDB();
chai_1.assert.ok(await client.listTables().promise());
}
catch (e) {
chai_1.assert.isOk(false, "Should be able to launch localstack");
console.error(e);
}
finally {
// server.stop();
}
});
it("Should be able to launch dynamodb docker", async () => {
const server = new __1.DynamoDBDocker();
try {
await server.start();
const client = new DynamoDB({
endpoint: server.getURL(),
region: "eu-central-1"
});
chai_1.assert.ok(await client.listTables().promise());
}
catch (e) {
chai_1.assert.isOk(false, "Should be able to launch dynamodb");
console.error(e);
}
finally {
// server.stop();
}
});
});
//# sourceMappingURL=index.js.map