From 1ef155d0698479803c52010b34a9c811c4cd0bf3 Mon Sep 17 00:00:00 2001 From: Vitalii Date: Tue, 14 Nov 2023 21:00:36 +0200 Subject: [PATCH] renamed_files_name new_commit --- .../CreateOrEditQuizContainer.tsx | 1 + .../my-quizzes/EditQuizContainer.spec.jsx | 96 ------------------- 2 files changed, 1 insertion(+), 96 deletions(-) delete mode 100644 tests/unit/containers/my-quizzes/EditQuizContainer.spec.jsx diff --git a/src/containers/my-quizzes/create-or-edit-quiz-container/CreateOrEditQuizContainer.tsx b/src/containers/my-quizzes/create-or-edit-quiz-container/CreateOrEditQuizContainer.tsx index b6937cf11e..bbaf3fd6c3 100644 --- a/src/containers/my-quizzes/create-or-edit-quiz-container/CreateOrEditQuizContainer.tsx +++ b/src/containers/my-quizzes/create-or-edit-quiz-container/CreateOrEditQuizContainer.tsx @@ -23,6 +23,7 @@ import PageWrapper from '~/components/page-wrapper/PageWrapper' import { snackbarVariants } from '~/constants' import { authRoutes } from '~/router/constants/authRoutes' import { myResourcesPath } from '~/pages/create-or-edit-lesson/CreateOrEditLesson.constants' + import { QuizContentProps } from '~/pages/new-quiz/NewQuiz.constants' import { styles } from '~/containers/my-quizzes/create-or-edit-quiz-container/CreateOrEditQuizContainer.styles' import { diff --git a/tests/unit/containers/my-quizzes/EditQuizContainer.spec.jsx b/tests/unit/containers/my-quizzes/EditQuizContainer.spec.jsx deleted file mode 100644 index f82b3aee0f..0000000000 --- a/tests/unit/containers/my-quizzes/EditQuizContainer.spec.jsx +++ /dev/null @@ -1,96 +0,0 @@ -import { vi } from 'vitest' -import EditQuizContainer from '~/containers/my-quizzes/edit-quiz-container/EditQuizContainer' -import { fireEvent, screen } from '@testing-library/react' -import { renderWithProviders } from '~tests/test-utils' - -vi.mock('~/hooks/use-categories-names', () => ({ - __esModule: true, - default: () => ({ - loading: false, - response: [ - { _id: '123', name: 'Category 1' }, - { _id: '456', name: 'Category 2' }, - { _id: '789', name: '' } - ] - }) -})) -const initialCategory = 'initialCategory' - -const route = '/categories/subjects?categoryId=123' -const mockState = { - appMain: { userRole: 'tutor' } -} - -describe('EditQuizContainer', () => { - beforeEach(() => { - renderWithProviders( - {}} - />, - { - initialEntries: route, - preloadedState: mockState - } - ) - }) - - afterEach(() => { - vi.clearAllMocks() - }) - - it('should render correctly', () => { - const autocomplete = screen.getByLabelText( - 'myResourcesPage.quizzes.categoryDropdown' - ) - expect(autocomplete).toBeInTheDocument() - }) - - it('should change autocomplete', () => { - const autocomplete = screen.getByLabelText( - 'myResourcesPage.quizzes.categoryDropdown' - ) - fireEvent.click(autocomplete) - fireEvent.change(autocomplete, { target: { value: 'Category 2' } }) - fireEvent.keyDown(autocomplete, { key: 'ArrowDown' }) - fireEvent.keyDown(autocomplete, { key: 'Enter' }) - expect(autocomplete.value).toBe('Category 2') - }) - - it('should clear autocomplete', () => { - const autocomplete = screen.getByLabelText( - 'myResourcesPage.quizzes.categoryDropdown' - ) - fireEvent.click(autocomplete) - fireEvent.change(autocomplete, { target: { value: '' } }) - fireEvent.keyDown(autocomplete, { key: 'ArrowDown' }) - fireEvent.keyDown(autocomplete, { key: 'Enter' }) - expect(autocomplete.value).toBe('') - }) - - it('should change title and description', () => { - const titleInput = screen.getByLabelText( - 'myResourcesPage.quizzes.defaultNewTitle' - ) - const descriptionInput = screen.getByLabelText( - 'myResourcesPage.quizzes.defaultNewDescription' - ) - fireEvent.change(titleInput, { target: { value: 'New Title' } }) - fireEvent.change(descriptionInput, { target: { value: 'New Description' } }) - 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('') - }) -})