Skip to content

Commit

Permalink
edited AdminPortal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OlyaKorchan committed Oct 5, 2023
1 parent 1f869a7 commit 2902d1c
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tests/unit/containers/admin-portal/AdminPortal.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import {
RouterProvider
} from 'react-router-dom'
import { routerConfig } from '~/router/router'
import { render, screen, waitFor } from '@testing-library/react'
import { render, screen } from '@testing-library/react'
import { Provider } from 'react-redux'
import { ThemeProvider } from '@mui/material/styles'
import { theme } from '~/styles/app-theme/custom-mui.styles'
import { beforeEach, expect } from 'vitest'

const renderWithRouter = (initialEntries, preloadedState) => {
import AdminPortal from '~/containers/layout/admin-portal/AdminPortal'

const renderAdminPortalRouter = (initialEntries, preloadedState) => {
const store = configureStore({
reducer: { appMain: reducer },
preloadedState
Expand All @@ -24,17 +26,19 @@ const renderWithRouter = (initialEntries, preloadedState) => {
render(
<Provider store={store}>
<ThemeProvider theme={theme}>
<RouterProvider router={router} />
<RouterProvider router={router}>
<AdminPortal />
</RouterProvider>
</ThemeProvider>
</Provider>
)
}

describe('Admin Portal tests', () => {
beforeEach(() => {
const preloadState = { appMain: { userRole: 'admin' } }
const preloadedState = { appMain: { userRole: 'admin' } }
const path = '/admin'
renderWithRouter(path, preloadState)
renderAdminPortalRouter(path, preloadedState)
})

it('should render loader', () => {
Expand All @@ -46,9 +50,4 @@ describe('Admin Portal tests', () => {
const adminNavBar = screen.getByTestId('AdminNavBar')
expect(adminNavBar).toBeInTheDocument()
})

it('should render admin home data as default', async () => {
const adminPagePlaceholder = await screen.findByText('Hello Admin!')
await waitFor(() => expect(adminPagePlaceholder).toBeInTheDocument())
})
})

0 comments on commit 2902d1c

Please sign in to comment.