UNPKG

@eagleeye-solutions/integration-events-common

Version:
49 lines 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const mockTopic = { publishMessage: jest.fn(), }; const mockPubSub = { topic: jest.fn().mockReturnValue(mockTopic), }; const mockLogger = { debug: jest.fn(), info: jest.fn(), error: jest.fn(), }; const gcp_1 = require("../../../src/platform/gcp"); const pubsub_1 = require("@google-cloud/pubsub"); jest.mock('@google-cloud/pubsub', () => { return { __esModule: true, PubSub: jest.fn().mockReturnValue(mockPubSub), }; }); describe('sendMessageToGcpPubSubTopic', () => { it('sends the message to the topic', async () => { // Arrange const appConfig = { platformConfig: { projectId: 'some-project', }, }; // Act const output = await (0, gcp_1.sendMessageToGcpPubSubTopic)(appConfig, 'some-name', { some: 'data', }, { some: 'attribute', }, mockLogger); // Assert expect(output).toBeUndefined(); expect(pubsub_1.PubSub).toHaveBeenCalledWith({ projectId: 'some-project' }); expect(mockTopic.publishMessage).toHaveBeenCalledWith({ json: { some: 'data', }, attributes: { some: 'attribute', }, }); }); }); //# sourceMappingURL=gcp.spec.js.map