Skip to content

Commit 0175c05

Browse files
committed
update test
Signed-off-by: Jackie Han <[email protected]>
1 parent 7ed9b1d commit 0175c05

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

public/pages/DetectorResults/__tests__/AnomalyResultsTable.test.tsx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,38 @@ jest.mock('../../../services', () => ({
2828
getDataSourceEnabled: jest.fn(),
2929
}));
3030

31+
jest.mock('react-router-dom', () => ({
32+
...jest.requireActual('react-router-dom'),
33+
useLocation: () => ({
34+
pathname: '/',
35+
search: '',
36+
hash: '',
37+
state: undefined,
38+
}),
39+
}));
40+
41+
jest.mock('../../../pages/utils/helpers', () => ({
42+
getDataSourceFromURL: jest.fn().mockReturnValue({
43+
dataSourceId: undefined,
44+
}),
45+
}));
46+
3147
const mockCoreServices = {
3248
uiSettings: {
3349
get: jest.fn().mockReturnValue(false),
3450
},
51+
workspaces: {
52+
currentWorkspace$: {
53+
pipe: jest.fn().mockReturnValue({
54+
toPromise: jest.fn().mockResolvedValue(null),
55+
}),
56+
},
57+
client$: {
58+
getValue: jest.fn().mockReturnValue({
59+
getCurrentWorkspaceId: jest.fn().mockReturnValue(null),
60+
}),
61+
},
62+
},
3563
};
3664

3765
const renderWithContext = (component: React.ReactElement) => {
@@ -191,16 +219,16 @@ describe('AnomalyResultsTable', () => {
191219
expect(discoverButton).toBeInTheDocument();
192220
});
193221

194-
it('hides Actions column when mds is enabled', () => {
222+
it('shows Actions column when mds is enabled', () => {
195223
(getDataSourceEnabled as jest.Mock).mockReturnValue({ enabled: true });
196224

197225
renderWithContext(<AnomalyResultsTable {...defaultProps} />);
198226

199227
const actionsColumn = screen.queryByText('Actions');
200-
expect(actionsColumn).not.toBeInTheDocument();
228+
expect(actionsColumn).toBeInTheDocument();
201229

202230
const discoverButton = screen.queryByTestId('discoverIcon');
203-
expect(discoverButton).not.toBeInTheDocument();
231+
expect(discoverButton).toBeInTheDocument();
204232
});
205233
});
206234
});

0 commit comments

Comments
 (0)