From 95380a8d7385932a917168357ad05c79f47cadfa Mon Sep 17 00:00:00 2001 From: Logan Nguyen Date: Fri, 31 Jan 2025 23:23:12 -0600 Subject: [PATCH] fix: fixed utils.spec.ts Signed-off-by: Logan Nguyen --- packages/relay/tests/lib/utils.spec.ts | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/packages/relay/tests/lib/utils.spec.ts b/packages/relay/tests/lib/utils.spec.ts index 4d97d1198..83831ee2d 100644 --- a/packages/relay/tests/lib/utils.spec.ts +++ b/packages/relay/tests/lib/utils.spec.ts @@ -180,15 +180,10 @@ describe('Utils', () => { OPERATOR_KEY_MAIN: null, }, () => { - it('should return null and log a warning if operatorKey is missing', () => { - const warnSpy = sinon.spy(logger, 'warn'); - - const operator = Utils.getOperator(logger); - - expect(operator).to.be.null; - expect(warnSpy.calledOnce).to.be.true; - expect(warnSpy.firstCall.args[0]).to.equal('Invalid operatorId or operatorKey for main client.'); - warnSpy.restore(); + it('should throw error if OPERATOR_KEY_MAIN is missing', () => { + expect(() => Utils.getOperator(logger)).to.throw( + 'Configuration error: OPERATOR_KEY_MAIN is a mandatory configuration for relay operation.', + ); }); }, ); @@ -199,15 +194,10 @@ describe('Utils', () => { OPERATOR_KEY_MAIN: privateKeys[0].keyValue, }, () => { - it('should return null and log a warning if operatorId is missing', () => { - const warnSpy = sinon.spy(logger, 'warn'); - - const operator = Utils.getOperator(logger); - - expect(operator).to.be.null; - expect(warnSpy.calledOnce).to.be.true; - expect(warnSpy.firstCall.args[0]).to.equal('Invalid operatorId or operatorKey for main client.'); - warnSpy.restore(); + it('should throw error if OPERATOR_ID_MAIN is missing', () => { + expect(() => Utils.getOperator(logger)).to.throw( + 'Configuration error: OPERATOR_ID_MAIN is a mandatory configuration for relay operation.', + ); }); }, );