From d00ec433666631ab663c96e3b4c8d7e24e78c2ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 20 Jul 2021 12:26:53 +0100 Subject: [PATCH] test(data-workspace): don't reset mocks before each test --- src/data-workspace/data-workspace.test.js | 31 +++++++++++------------ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/data-workspace/data-workspace.test.js b/src/data-workspace/data-workspace.test.js index 42283447..1f922fd7 100644 --- a/src/data-workspace/data-workspace.test.js +++ b/src/data-workspace/data-workspace.test.js @@ -28,23 +28,18 @@ const mockDataSets = [ }, ] -beforeEach(() => { - useWorkflowContext.mockImplementation(() => ({ - displayName: 'Workflow a', - id: 'i5m0JPw4DQi', - periodType: 'Monthly', - dataSets: mockDataSets, - approvalState: 'APPROVED_HERE', - })) - useSelectionParams.mockImplementation(() => ({ - pe: '201204', - ou: 'ImspTQPwCqd', - })) -}) +useWorkflowContext.mockImplementation(() => ({ + displayName: 'Workflow a', + id: 'i5m0JPw4DQi', + periodType: 'Monthly', + dataSets: mockDataSets, + approvalState: 'APPROVED_HERE', +})) -afterEach(() => { - jest.resetAllMocks() -}) +useSelectionParams.mockImplementation(() => ({ + pe: '201204', + ou: 'ImspTQPwCqd', +})) describe('', () => { it('renders a TitleBar, DataSetNavigation and Display', () => { @@ -75,6 +70,9 @@ describe('', () => { it('if there is more than one data set, do not select one automatically', () => { const wrapper = shallow() + expect( + wrapper.find(DataSetNavigation).prop('dataSets').length + ).toBeGreaterThan(0) expect(wrapper.find(DataSetNavigation).prop('selected')).toBe(null) expect(wrapper.find(Display).prop('dataSetId')).toBe(null) }) @@ -89,6 +87,7 @@ describe('', () => { })) const wrapper = shallow() + expect(wrapper.find(DataSetNavigation).prop('dataSets')).toHaveLength(0) expect(wrapper.find(DataSetNavigation).prop('selected')).toBe(null) expect(wrapper.find(Display).prop('dataSetId')).toBe(null) })