Skip to content

Commit

Permalink
added_additional_test
Browse files Browse the repository at this point in the history
  • Loading branch information
mynotdoing committed Nov 16, 2023
1 parent 861175d commit 33b90fc
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/unit/containers/my-quizzes/EditQuizContainer.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ vi.mock('~/hooks/use-categories-names', () => ({
]
})
}))
const initialCategory = 'initialCategory'

const route = '/categories/subjects?categoryId=123'
const mockState = {
Expand All @@ -23,7 +24,11 @@ const mockState = {
describe('EditQuizContainer', () => {
beforeEach(() => {
renderWithProviders(
<EditQuizContainer questions={[]} setQuestions={() => {}} />,
<EditQuizContainer
initialCategory={initialCategory}
questions={[]}
setQuestions={() => {}}
/>,
{
initialEntries: route,
preloadedState: mockState
Expand Down Expand Up @@ -63,6 +68,7 @@ describe('EditQuizContainer', () => {
fireEvent.keyDown(autocomplete, { key: 'Enter' })
expect(autocomplete.value).toBe('')
})

it('should change title and description', () => {
const titleInput = screen.getByLabelText(
'myResourcesPage.quizzes.defaultNewTitle'
Expand All @@ -75,4 +81,16 @@ describe('EditQuizContainer', () => {
expect(titleInput.value).toBe('New Title')
expect(descriptionInput.value).toBe('New Description')
})

it('should update the category, when new category is choosen', () => {
const categoryInput = screen.getByLabelText(
'myResourcesPage.quizzes.categoryDropdown'
)

fireEvent.change(categoryInput, {
target: { value: 'Category 2' }
})

expect(categoryInput.value).toBe('')
})
})

0 comments on commit 33b90fc

Please sign in to comment.