Skip to content

Commit f511f8c

Browse files
Refactor tests
1 parent 959112e commit f511f8c

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

src/pages/ConsumerPurposeTemplateListPage/__test__/ConsumerPurposeTemplateListPage.test.tsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,44 @@ import { mockUseJwt, renderWithApplicationContext } from '@/utils/testing.utils'
22
import ConsumerPurposeTemplateListPage from '../ConsumerPurposeTemplateList.page'
33
import { screen } from '@testing-library/react'
44
import userEvent from '@testing-library/user-event'
5-
import { ConsumerPurposeTemplateTable } from '../components/ConsumerPurposeTemplateTable'
65

76
mockUseJwt()
87

9-
describe('Purpose Template list page', () => {
10-
it('should be visibile Purpose Template list page with title, the table and create button', () => {
8+
// vi.mock('../ConsumerPurposeTemplateTable', () => ({
9+
// ConsumerPurposeTemplateTable: () => <div>purpose-template-table</div>,
10+
// ConsumerPurposeTemplateTableSkeleton: () => <div>purpose-template-table-skeleton</div>,
11+
// }))
12+
13+
describe('ConsumerPurposeTemplateListPage', () => {
14+
beforeEach(() => {
1115
renderWithApplicationContext(<ConsumerPurposeTemplateListPage />, {
12-
withRouterContext: true,
1316
withReactQueryContext: true,
17+
withRouterContext: true,
1418
})
15-
expect(screen.getByText('title')).toBeInTheDocument()
16-
expect(screen.getByText('createNewBtn')).toBeInTheDocument()
17-
expect(screen.getByRole('table')).toBeInTheDocument()
1819
})
1920

20-
it('should open the dialog when clicking the create button', async () => {
21-
renderWithApplicationContext(<ConsumerPurposeTemplateListPage />, {
22-
withRouterContext: true,
23-
withReactQueryContext: true,
21+
// describe('ConsumerPurposeTemplateListPage is loading data', () => {
22+
// it('Should be render the skeleton at the beginning', () => {
23+
// expect(screen.getByText('purpose-template-table-skeleton')).toBeInTheDocument()
24+
// })
25+
// }) TODO: IT'S NOT WORKING
26+
27+
describe('Purpose Template list page', () => {
28+
it('should be visibile Purpose Template list page with title, the table and create button', () => {
29+
expect(screen.getByText('title')).toBeInTheDocument()
30+
expect(screen.getByText('createNewBtn')).toBeInTheDocument()
31+
expect(screen.getByRole('table')).toBeInTheDocument()
2432
})
33+
})
34+
35+
it('should open the dialog when clicking the create button', async () => {
2536
const createButton = screen.getByText('createNewBtn')
2637
await userEvent.click(createButton)
2738

2839
expect(await screen.findByTestId('create-purpose-modal')).toBeInTheDocument()
2940
})
3041

3142
it('should be have four columns (intended target, purpose template, status, actions)', () => {
32-
renderWithApplicationContext(<ConsumerPurposeTemplateTable purposeTemplates={[]} />, {
33-
withRouterContext: true,
34-
withReactQueryContext: true,
35-
})
3643
expect(screen.getAllByRole('columnheader')).toHaveLength(4)
3744
})
3845
})

0 commit comments

Comments
 (0)