/** * SNSGateway Unit Tests */ import * as AWS from "aws-sdk-mock"; import { PublishResponse } from "aws-sdk/clients/sns"; import { expect } from "chai"; import { IDENTIFIERS } from "constant/Identifiers"; import { CONTAINER } from "infrastructure/Container"; import { ISNSGateway } from "repository/ISNSGateway"; import { createSandbox, SinonSandbox } from "sinon"; let gateway: ISNSGateway | undefined; let gSandbox: SinonSandbox; describe("SNSGateway -", () => { beforeEach(async () => { gSandbox = createSandbox(); }); afterEach(() => { gSandbox.restore(); AWS.restore("SNS", "publish"); gateway = undefined; }); it("test SNS put", (done: Mocha.Done) => { const expected_response: PublishResponse = { MessageId: "test-message" }; AWS.mock("SNS", "publish", expected_response); gateway = CONTAINER.get(IDENTIFIERS.SNSGateway); gateway.publish("arn", {}).subscribe( (data: boolean) => { expect(data).to.be.true; }, done, done ); }); });