From 6ee39c9d3a14c2dd56f0aa53602afc4b3b246344 Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Wed, 18 Dec 2024 08:49:55 -0800 Subject: [PATCH] update unit tests Signed-off-by: Tony Lee --- .../utils/create_dashboard_app_state.test.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/dashboard/public/application/utils/create_dashboard_app_state.test.tsx b/src/plugins/dashboard/public/application/utils/create_dashboard_app_state.test.tsx index 6d8d2008345b..c2099a029d29 100644 --- a/src/plugins/dashboard/public/application/utils/create_dashboard_app_state.test.tsx +++ b/src/plugins/dashboard/public/application/utils/create_dashboard_app_state.test.tsx @@ -159,7 +159,7 @@ describe('updateStateUrl', () => { rawHistory.push(basePath); const history = new ScopedHistory(rawHistory, basePath); - const changed = updateStateUrl({ + updateStateUrl({ osdUrlStateStorage, state: dashboardAppState, scopedHistory: history, @@ -170,7 +170,6 @@ describe('updateStateUrl', () => { replace: true, }); expect(osdUrlStateStorage.flush).toHaveBeenCalledWith({ replace: true }); - expect(changed).toBe(true); }); test('preserve Dashboards scoped history state', () => { @@ -180,9 +179,11 @@ describe('updateStateUrl', () => { const rawHistory = createMemoryHistory(); rawHistory.push(basePath); const history = new ScopedHistory(rawHistory, basePath); + const replaceSpy = jest.spyOn(history, 'replace'); history.push(newPath, someState); + const { location } = history; - updateStateUrl({ + const changed = updateStateUrl({ osdUrlStateStorage, state: dashboardAppState, scopedHistory: history, @@ -191,5 +192,7 @@ describe('updateStateUrl', () => { expect(history.location.pathname).toEqual(newPath); expect(history.location.state).toEqual(someState); + expect(changed).toBe(true); + expect(replaceSpy).toHaveBeenCalledWith({ ...location, state: someState }); }); });