diff --git a/src/microservice/gcloud-pub-sub.server.spec.ts b/src/microservice/gcloud-pub-sub.server.spec.ts index de81efb..3268040 100644 --- a/src/microservice/gcloud-pub-sub.server.spec.ts +++ b/src/microservice/gcloud-pub-sub.server.spec.ts @@ -44,17 +44,17 @@ describe('GCloudPubSubServer', () => { expect(server.client).toBe(null) expect(server.subscriptions.length).toBe(0) expect(server.options).toMatchInlineSnapshot(` - Object { - "authOptions": Object { + { + "authOptions": { "projectId": "entitlement", }, - "subscriberOptions": Object { - "flowControl": Object { + "subscriberOptions": { + "flowControl": { "allowExcessMessages": false, "maxMessages": 5, }, }, - "subscriptionIds": Array [ + "subscriptionIds": [ "create", "update", "delete", @@ -71,11 +71,11 @@ describe('GCloudPubSubServer', () => { expect(server2.client).toBe(null) expect(server2.subscriptions.length).toBe(0) expect(server2.options).toMatchInlineSnapshot(` - Object { - "authOptions": Object { + { + "authOptions": { "projectId": "entitlement", }, - "subscriptionIds": Array [ + "subscriptionIds": [ "create", "update", "delete", @@ -137,21 +137,21 @@ describe('GCloudPubSubServer', () => { message.ack.mockReset() }) - it('Acks the message and returns when no handler can be found', async () => { + it('Acks the message and returns when no handler can be found', () => { server.listen(() => {}) const subscriptionName = 'my-subscription' server.getHandlerByPattern = jest.fn(pattern => { expect(pattern).toBe(subscriptionName) return null }) - const handleMessage = await server.handleMessageFactory(subscriptionName) + const handleMessage = server.handleMessageFactory(subscriptionName) // @ts-ignore handleMessage(message) expect(server.getHandlerByPattern).toHaveBeenCalled() expect(message.ack).toHaveBeenCalled() }) - it('Calls the handler when a handler is found', async () => { + it('Calls the handler when a handler is found', () => { const mockHandler = jest.fn() const subscriptionName = 'my-subscription' server.listen(() => {}) @@ -160,7 +160,7 @@ describe('GCloudPubSubServer', () => { expect(pattern).toBe(subscriptionName) return mockHandler }) - const handleMessage = await server.handleMessageFactory(subscriptionName) + const handleMessage = server.handleMessageFactory(subscriptionName) // @ts-ignore handleMessage(message) expect(server.getHandlerByPattern).toHaveBeenCalledTimes(1) @@ -193,7 +193,6 @@ describe('GCloudPubSubServer', () => { }) it('retries calling open on the subscription when error is in PUB_SUB_DEFAULT_RETRY_CODES', done => { - jest.setTimeout(TIMEOUT) const subscription = { close: jest.fn(), open: jest.fn(() => { @@ -212,7 +211,7 @@ describe('GCloudPubSubServer', () => { expect(subscription.close).toHaveBeenCalled() // @ts-ignore expect(server.handleError).toHaveBeenCalledWith(error) - }) + }, TIMEOUT) it('does not attempt to handle subscription error retry when server is closing', () => { jest.setTimeout(TIMEOUT) diff --git a/src/microservice/gcloud-pub-sub.server.ts b/src/microservice/gcloud-pub-sub.server.ts index 6664ded..3da921f 100644 --- a/src/microservice/gcloud-pub-sub.server.ts +++ b/src/microservice/gcloud-pub-sub.server.ts @@ -32,7 +32,7 @@ export class GCloudPubSubServer extends Server implements CustomTransportStrateg } public handleErrorFactory(subscription: Subscription, subcriptionName: string) { - return error => { + return (error): void => { this.handleError(error) if (!this.isShuttingDown && PUB_SUB_DEFAULT_RETRY_CODES.includes(error.code)) { this.logger.warn(`Closing subscription: ${subcriptionName}`)