diff --git a/src/__tests__/zeebe/integration/Client-ConnectionError.spec.ts b/src/__tests__/zeebe/integration/Client-ConnectionError.spec.ts index 661c8823..2f532030 100644 --- a/src/__tests__/zeebe/integration/Client-ConnectionError.spec.ts +++ b/src/__tests__/zeebe/integration/Client-ConnectionError.spec.ts @@ -25,13 +25,13 @@ test('Calls the onConnectionError handler if there is no broker and eagerConnect }, 7000) })) -test('Sets connected:false if there is no broker and no setting of eagerConnection', () => +test('Sets connected:undefined if there is no broker and no setting of eagerConnection', () => new Promise((done) => { const zbc2 = new ZeebeGrpcClient({ config: { ZEEBE_ADDRESS: 'localtoast: 267890' }, }) // Broker doesn't exist!!! setTimeout(async () => { - expect(zbc2.connected).toBe(false) + expect(zbc2.connected).toBe(undefined) await zbc2.close() done(null) }, 5000) diff --git a/src/__tests__/zeebe/integration/Client-onReady.spec.ts b/src/__tests__/zeebe/integration/Client-onReady.spec.ts index a6a1f65c..77626644 100644 --- a/src/__tests__/zeebe/integration/Client-onReady.spec.ts +++ b/src/__tests__/zeebe/integration/Client-onReady.spec.ts @@ -20,7 +20,7 @@ test('Does not call the onReady handler if there is no broker', (done) => { }, 4000) }) -test('Does call the onReady handler if there is a broker and eagerConnection is true', (done) => { +test('Calls the onReady handler if there is a broker and eagerConnection is true', (done) => { let called = 0 const zbc2 = new ZeebeGrpcClient({ config: { zeebeGrpcSettings: { ZEEBE_GRPC_CLIENT_EAGER_CONNECT: true } }, @@ -35,7 +35,7 @@ test('Does call the onReady handler if there is a broker and eagerConnection is }, 6000) }) -test('Does set connected to true if there is a broker', (done) => { +test('Sets connected to true if there is a broker', (done) => { const zbc2 = new ZeebeGrpcClient({ config: { zeebeGrpcSettings: { ZEEBE_GRPC_CLIENT_EAGER_CONNECT: true } }, }) @@ -47,7 +47,7 @@ test('Does set connected to true if there is a broker', (done) => { }, 6000) }) -test('Does emit the ready event if there is a broker and eagerConnection: true', (done) => { +test('emits the ready event if there is a broker and eagerConnection: true', (done) => { let called = 0 const zbc2 = new ZeebeGrpcClient({ config: { zeebeGrpcSettings: { ZEEBE_GRPC_CLIENT_EAGER_CONNECT: true } }, diff --git a/src/__tests__/zeebe/integration/Worker-onReady.spec.ts b/src/__tests__/zeebe/integration/Worker-onReady.spec.ts index d1c60c78..ee0bfa6e 100644 --- a/src/__tests__/zeebe/integration/Worker-onReady.spec.ts +++ b/src/__tests__/zeebe/integration/Worker-onReady.spec.ts @@ -36,10 +36,10 @@ test('Does set connected: true if there is a broker and eagerConnection: true', }, 7000) }) -test('Does not set connected: true if there is a broker and eagerConnection: false', (done) => { +test('Sets connected: true if there is a broker and eagerConnection: false', (done) => { const zbc2 = new ZeebeGrpcClient() setTimeout(async () => { - expect(zbc2.connected).toBe(false) + expect(zbc2.connected).toBe(true) await zbc2.close() done() }, 7000) diff --git a/src/zeebe/lib/GrpcClient.ts b/src/zeebe/lib/GrpcClient.ts index b6d42f0e..b6529b7e 100644 --- a/src/zeebe/lib/GrpcClient.ts +++ b/src/zeebe/lib/GrpcClient.ts @@ -276,7 +276,8 @@ export class GrpcClient extends EventEmitter { }) this.listNameMethods = [] - this.client.waitForReady(10000, (error) => + // See https://github.com/camunda/camunda-8-js-sdk/issues/150 + this.client.waitForReady(new Date(Date.now() + 10000), (error) => error ? this.emit(MiddlewareSignals.Event.Error, error) : this.emit(MiddlewareSignals.Event.Ready)