From 7c4dec088fb4705dc4fc6650ea62bb5223e1d41d Mon Sep 17 00:00:00 2001 From: lizozom Date: Thu, 3 Mar 2022 19:25:00 +0200 Subject: [PATCH] code review --- .../execution_context_service.test.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/core/public/execution_context/execution_context_service.test.ts b/src/core/public/execution_context/execution_context_service.test.ts index 2b8daf9513aa9..70e57b8993bb1 100644 --- a/src/core/public/execution_context/execution_context_service.test.ts +++ b/src/core/public/execution_context/execution_context_service.test.ts @@ -43,7 +43,7 @@ describe('ExecutionContextService', () => { }); }); - it('sets context and adds curr url and appid when getting it', () => { + it('sets context and adds current url and appid when getting it', () => { execContext.set({ type: 'ghf', description: 'first set', @@ -78,16 +78,14 @@ describe('ExecutionContextService', () => { it('context observable fires the context each time it changes', () => { const sub = jest.fn(); - execContext.context$.subscribe(sub); - - // sub gets called immediately with the current value as it's a behavior subject - sub.mockReset(); execContext.set({ type: 'ghf', description: 'first set', }); + execContext.context$.subscribe(sub); + expect(sub).toHaveBeenCalledWith({ name: 'app1', type: 'ghf', @@ -112,14 +110,14 @@ describe('ExecutionContextService', () => { it('context observable doesnt fires if the context did not change', () => { const sub = jest.fn(); - execContext.context$.subscribe(sub); - sub.mockReset(); execContext.set({ type: 'ghf', description: 'first set', }); + execContext.context$.subscribe(sub); + execContext.set({ type: 'ghf', }); @@ -134,15 +132,14 @@ describe('ExecutionContextService', () => { expect(sub).toHaveBeenCalledTimes(1); }); - it('context is cleared and observable is triggered', () => { + it('clear resets context and triggers context observable', () => { const sub = jest.fn(); - execContext.context$.subscribe(sub); - sub.mockReset(); execContext.set({ type: 'ghf', description: 'first set', }); + execContext.context$.subscribe(sub); execContext.clear(); expect(sub).toHaveBeenCalledWith({