Skip to content

Commit e2e71e5

Browse files
committed
fix tests in SentinelDatabasesPage.spec.tsx
1 parent 51fa351 commit e2e71e5

File tree

2 files changed

+10
-40
lines changed

2 files changed

+10
-40
lines changed

redisinsight/ui/src/pages/autodiscover-sentinel/sentinel-databases/SentinelDatabasesPage.spec.tsx

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import React from 'react'
2-
import { render, screen, fireEvent } from 'uiSrc/utils/test-utils'
3-
4-
import { Table } from 'uiSrc/components/base/layout/table'
2+
import { fireEvent, render, screen } from 'uiSrc/utils/test-utils'
53
import SentinelDatabasesPage from './SentinelDatabasesPage'
6-
import SentinelDatabases from './components'
7-
import { Props as SentinelDatabasesProps } from './components/SentinelDatabases/SentinelDatabases'
84

95
jest.mock('uiSrc/slices/instances/sentinel', () => ({
106
sentinelSelector: jest.fn().mockReturnValue({
@@ -25,63 +21,32 @@ jest.mock('uiSrc/slices/instances/sentinel', () => ({
2521
resetDataSentinel: jest.fn,
2622
}))
2723

28-
jest.mock('./components', () => ({
29-
__esModule: true,
30-
namedExport: jest.fn(),
31-
default: jest.fn(),
32-
}))
33-
34-
const mockSentinelDatabases = (props: SentinelDatabasesProps) => (
35-
<div>
36-
<button
37-
type="button"
38-
onClick={() => props.onClose()}
39-
data-testid="close-btn"
40-
>
41-
onClose
42-
</button>
43-
<button type="button" onClick={() => props.onBack()} data-testid="back-btn">
44-
onBack
45-
</button>
46-
<button
47-
type="button"
48-
onClick={() => props.onSubmit([])}
49-
data-testid="submit-btn"
50-
>
51-
onSubmit
52-
</button>
53-
<Table columns={props.columns} data={props.masters} />
54-
</div>
55-
)
56-
5724
/**
5825
* SentinelDatabasesPage tests
5926
*
6027
* @group component
6128
*/
6229
describe('SentinelDatabasesPage', () => {
63-
beforeAll(() => {
64-
SentinelDatabases.mockImplementation(mockSentinelDatabases)
65-
})
6630
it('should render', () => {
6731
expect(render(<SentinelDatabasesPage />)).toBeTruthy()
6832
})
6933

7034
it('should call onClose', () => {
7135
const component = render(<SentinelDatabasesPage />)
72-
fireEvent.click(screen.getByTestId('close-btn'))
36+
fireEvent.click(screen.getByTestId('btn-cancel'))
37+
fireEvent.click(screen.getByTestId('btn-cancel-proceed'))
7338
expect(component).toBeTruthy()
7439
})
7540

7641
it('should call onBack', () => {
7742
const component = render(<SentinelDatabasesPage />)
78-
fireEvent.click(screen.getByTestId('back-btn'))
43+
fireEvent.click(screen.getByTestId('btn-back-adding'))
7944
expect(component).toBeTruthy()
8045
})
8146

8247
it('should call onSubmit', () => {
8348
const component = render(<SentinelDatabasesPage />)
84-
fireEvent.click(screen.getByTestId('submit-btn'))
49+
fireEvent.click(screen.getByTestId('btn-add-primary-group'))
8550
expect(component).toBeTruthy()
8651
})
8752

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import SentinelDatabases from './SentinelDatabases'
2+
3+
export { SentinelDatabases }
4+
5+
export default SentinelDatabases

0 commit comments

Comments
 (0)