From d53b869d65791bab29c05b3666d2bc227ac4068c Mon Sep 17 00:00:00 2001 From: Loi Phan Date: Fri, 1 Dec 2023 17:45:13 +0700 Subject: [PATCH 1/2] Add unit test --- .../__snapshots__/AppLayout.test.tsx.snap | 2 + .../Header/__snapshots__/Header.test.tsx.snap | 2 + .../__snapshots__/HeaderMenu.test.tsx.snap | 2 + .../__snapshots__/index.test.tsx.snap | 202 ++++++++++++++++++ .../src/components/Pagination/index.test.tsx | 46 ++++ .../src/components/Search/Search.test.tsx | 79 +++---- .../Search/__snapshots__/Search.test.tsx.snap | 72 +++++++ .../userRoomAvailableContext.test.tsx | 34 ++- .../src/helpers/__tests__/helpers.test.ts | 10 +- .../src/helpers/__tests__/validators.test.ts | 21 ++ hotel-management/src/helpers/helper.ts | 10 - .../__tests__/useAccount.test.ts | 35 +++ 12 files changed, 450 insertions(+), 65 deletions(-) create mode 100644 hotel-management/src/components/Pagination/__snapshots__/index.test.tsx.snap create mode 100644 hotel-management/src/components/Pagination/index.test.tsx create mode 100644 hotel-management/src/components/Search/__snapshots__/Search.test.tsx.snap create mode 100644 hotel-management/src/hooks/authentication/__tests__/useAccount.test.ts diff --git a/hotel-management/src/components/AppLayout/__snapshots__/AppLayout.test.tsx.snap b/hotel-management/src/components/AppLayout/__snapshots__/AppLayout.test.tsx.snap index dc7ccf8..a1bf590 100644 --- a/hotel-management/src/components/AppLayout/__snapshots__/AppLayout.test.tsx.snap +++ b/hotel-management/src/components/AppLayout/__snapshots__/AppLayout.test.tsx.snap @@ -16,6 +16,7 @@ exports[`AppLayout Should render correctly 1`] = ` >
  • + + + + + , + "container":
    +
    +

    + Showing + 1 + to + 5 + of + + 10 + + results +

    +
    + + +
    +
    +
    , + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; diff --git a/hotel-management/src/components/Pagination/index.test.tsx b/hotel-management/src/components/Pagination/index.test.tsx new file mode 100644 index 0000000..be2dc33 --- /dev/null +++ b/hotel-management/src/components/Pagination/index.test.tsx @@ -0,0 +1,46 @@ +import { render, fireEvent, RenderResult } from '@testing-library/react'; +import Pagination from '.'; +import { BrowserRouter } from 'react-router-dom'; + +describe('Pagination', () => { + const count = 10; + let wrapper: RenderResult | null = null; + + jest.mock('react-router-dom', () => ({ + useSearchParams: jest.fn(() => [new URLSearchParams(), jest.fn()]), + })); + + beforeEach(() => { + wrapper = render( + + + + ); + }); + + test('Should render correctly', () => { + expect(wrapper).toMatchSnapshot(); + }); + + test('Next button should be disable when in the last page', () => { + fireEvent.click(wrapper!.getByText('Next')); + + expect(wrapper!.getByText('Next').closest('button')).toBeDisabled(); + }); + + test('Previous button should not be disable when move to second page', () => { + fireEvent.click(wrapper!.getByText('Next')); + + expect(wrapper!.getByText('Previous').closest('button')).not.toBeDisabled(); + }); + + test('Previous button should be disabled when go back to the first page', () => { + // Navigate to the second page + fireEvent.click(wrapper!.getByText('Next')); + + // Back to the first page + fireEvent.click(wrapper!.getByText('Previous')); + + expect(wrapper!.getByText('Previous').closest('button')).toBeDisabled(); + }); +}); diff --git a/hotel-management/src/components/Search/Search.test.tsx b/hotel-management/src/components/Search/Search.test.tsx index fd3fb05..dd66555 100644 --- a/hotel-management/src/components/Search/Search.test.tsx +++ b/hotel-management/src/components/Search/Search.test.tsx @@ -1,67 +1,42 @@ -import { BrowserRouter } from 'react-router-dom'; -import { useState } from 'react'; +import { BrowserRouter, useSearchParams } from 'react-router-dom'; // Components import Search from '.'; -import { - RenderResult, - fireEvent, - render, - act, -} from '@testing-library/react'; +import { RenderResult, fireEvent, render } from '@testing-library/react'; -let mockSearchParam = ''; - -jest.useFakeTimers(); jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), - useSearchParams: () => { - const [params, setParams] = useState(new URLSearchParams(mockSearchParam)); - return [ - params, - (newParams: string) => { - mockSearchParam = newParams; - setParams(new URLSearchParams(newParams)); - }, - ]; - }, + useSearchParams: jest.fn(), +})); + +jest.mock('@hook/useDebounce', () => ({ + useDebounce: jest.fn((value) => value), })); describe('Search', () => { - // const placeHolder = 'Search placeholder...'; - // let wrapper: RenderResult | null = null; + const mockSearchParams = new URLSearchParams(); + (useSearchParams as jest.Mock).mockReturnValue([mockSearchParams, jest.fn()]); + let wrapper: RenderResult | null = null; - // beforeEach(() => { - // wrapper = render( - // - // - // - // ); - // }); - - // test('Should render correctly', () => { - // expect(wrapper).toMatchSnapshot(); - // }); - - test('Should add query to url after 1 second', async () => { - let wrapper: RenderResult | null = null; - act(() => { - wrapper = render( - - - - ); - }); - - const searchField = await wrapper!.findByPlaceholderText( - 'Search placeholder...' + beforeEach(() => { + wrapper = render( + + + ); + }); - act(() => { - fireEvent.change(searchField, { target: { value: 'abc' } }); - }); + test('Should render correctly', () => { + expect(wrapper).toMatchSnapshot(); + }) - // jest.advanceTimersByTime(1000); + test('updates searchParams on input change', () => { + const searchInput = wrapper!.getByPlaceholderText('Search'); + + // Type into the search input + fireEvent.change(searchInput, { target: { value: 'Search value' } }); + + // Expect searchParams to be updated + expect(mockSearchParams.get('search')).toBe('Search value'); }); }); - \ No newline at end of file diff --git a/hotel-management/src/components/Search/__snapshots__/Search.test.tsx.snap b/hotel-management/src/components/Search/__snapshots__/Search.test.tsx.snap new file mode 100644 index 0000000..544f2a0 --- /dev/null +++ b/hotel-management/src/components/Search/__snapshots__/Search.test.tsx.snap @@ -0,0 +1,72 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Search Should render correctly 1`] = ` +{ + "asFragment": [Function], + "baseElement": +
    + +
    + , + "container":
    + +
    , + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; diff --git a/hotel-management/src/contexts/__tests__/userRoomAvailableContext.test.tsx b/hotel-management/src/contexts/__tests__/userRoomAvailableContext.test.tsx index 672476c..1d19412 100644 --- a/hotel-management/src/contexts/__tests__/userRoomAvailableContext.test.tsx +++ b/hotel-management/src/contexts/__tests__/userRoomAvailableContext.test.tsx @@ -38,12 +38,14 @@ describe('userRoomAvailableContext', () => { { id: 1, name: 'Room 1', + status: true, }, ], usersAvailable: [ { id: 1, name: 'Nezumi', + isBooked: true, }, ], }; @@ -84,7 +86,8 @@ describe('userRoomAvailableContext', () => { expect(state.usersAvailable[0]).toEqual({ id: 1, - name: 'Update name' + name: 'Update name', + isBooked: true, }); }); @@ -123,7 +126,34 @@ describe('userRoomAvailableContext', () => { expect(state.roomsAvailable[0]).toEqual({ id: 1, - name: 'Update name' + name: 'Update name', + status: true, + }); + }); + + test('Should update room status correctly', async () => { + const state = reducer(initialState, { + type: 'updateStatusRoom', + payload: [{ id: 1, status: false }], + }); + + expect(state.roomsAvailable[0]).toEqual({ + id: 1, + name: 'Room 1', + status: false, + }); + }); + + test('Should update user status correctly', async () => { + const state = reducer(initialState, { + type: 'updateStatusUser', + payload: [{ id: 1, isBooked: false }], + }); + + expect(state.usersAvailable[0]).toEqual({ + id: 1, + name: 'Nezumi', + isBooked: false, }); }); }); diff --git a/hotel-management/src/helpers/__tests__/helpers.test.ts b/hotel-management/src/helpers/__tests__/helpers.test.ts index 8e71b7f..1594be5 100644 --- a/hotel-management/src/helpers/__tests__/helpers.test.ts +++ b/hotel-management/src/helpers/__tests__/helpers.test.ts @@ -1,5 +1,5 @@ // Helpers -import { formatCurrency } from '@helper/helper'; +import { formatCurrency, getDayDiff } from '@helper/helper'; describe('formatCurrency', () => { test('Should format correctly', () => { @@ -8,3 +8,11 @@ describe('formatCurrency', () => { expect(result).toEqual('$5,000.00'); }); }); + +describe('getDayDiff', () => { + test('Should calculate correctly', () => { + const result = getDayDiff(new Date('2023/11/30'), new Date('2023/12/01')); + + expect(result).toEqual(1); + }); +}); diff --git a/hotel-management/src/helpers/__tests__/validators.test.ts b/hotel-management/src/helpers/__tests__/validators.test.ts index 61d6b94..2d6be25 100644 --- a/hotel-management/src/helpers/__tests__/validators.test.ts +++ b/hotel-management/src/helpers/__tests__/validators.test.ts @@ -3,6 +3,7 @@ import { REGEX } from '@constant/commons'; // Helpers import { + compareTwoDates, isValidDiscount, isValidRegex, isValidString, @@ -88,3 +89,23 @@ describe('Should is valid string', () => { expect(case_4).toBeFalsy(); }); }); + +describe('Should compare two dates correctly', () => { + test('The start date should greater than end date', () => { + const result = compareTwoDates( + new Date('2023/12/05'), + new Date('2023/12/01') + ); + + expect(result).toBe(true); + }); + + test('The start date should fewer than end date', () => { + const result = compareTwoDates( + new Date('2023/12/01'), + new Date('2023/12/05') + ); + + expect(result).toBe(false); + }); +}); diff --git a/hotel-management/src/helpers/helper.ts b/hotel-management/src/helpers/helper.ts index dce6e83..0383c67 100644 --- a/hotel-management/src/helpers/helper.ts +++ b/hotel-management/src/helpers/helper.ts @@ -25,17 +25,7 @@ const getDayDiff = (startDate: Date, endDate: Date): number => { ); } -/** - * Convert from currency string to the number - * @param currency The currency string - * @returns The number - */ -const convertCurrencyToNumber = (currency: string) => { - return Number(currency.replace(/[^0-9.-]+/g,"")) -} - export { formatCurrency, getDayDiff, - convertCurrencyToNumber }; diff --git a/hotel-management/src/hooks/authentication/__tests__/useAccount.test.ts b/hotel-management/src/hooks/authentication/__tests__/useAccount.test.ts new file mode 100644 index 0000000..4ed1447 --- /dev/null +++ b/hotel-management/src/hooks/authentication/__tests__/useAccount.test.ts @@ -0,0 +1,35 @@ + +import { useQuery } from '@tanstack/react-query'; +import * as authenticationService from '@service/authenticationService'; +import { renderHook } from '@testing-library/react'; +import { User } from '@supabase/supabase-js'; +import { useAccount } from '../useAccount'; + +jest.mock('@tanstack/react-query'); + +describe('useAccount', () => { + it('Should return the value correctly', async () => { + const mockAccount: User = { + role: 'authenticated', + app_metadata: jest.fn(), + id: '1', + user_metadata: jest.fn(), + aud: '', + created_at: '' + }; + + (useQuery as jest.Mock).mockReturnValue({ + data: mockAccount, + isPending: false, + }); + + jest.spyOn(authenticationService, 'getCurrentAccount').mockResolvedValue(mockAccount); + + const { result } = renderHook(() => useAccount()); + + expect(result.current.isPending).toBe(false); + expect(result.current.account).toBe(mockAccount); + expect(result.current.isAuthenticated).toBe(true); + }); + +}); From 5d5eb1adaf579e7bacf69e8bd8f413c03729a0c5 Mon Sep 17 00:00:00 2001 From: Loi Phan Date: Sun, 3 Dec 2023 22:22:36 +0700 Subject: [PATCH 2/2] Update test case, fix comments --- hotel-management/package.json | 2 - hotel-management/pnpm-lock.yaml | 42 +- hotel-management/src/App.test.tsx | 4 + hotel-management/src/App.tsx | 2 +- .../src/__snapshots__/App.test.tsx.snap | 4 +- hotel-management/src/commons/styles/Input.ts | 6 +- .../src/commons/styles/Spinner.ts | 5 +- .../components/AppLayout/AppLayout.test.tsx | 6 +- .../__snapshots__/AppLayout.test.tsx.snap | 540 +++++++++++------- .../src/components/AppLayout/styled.ts | 2 +- .../components/ButtonIcon/ButtonIcon.test.tsx | 10 +- .../__snapshots__/ButtonIcon.test.tsx.snap | 146 +++-- .../ConfirmMessage/ConfirmMessage.test.tsx | 3 +- .../src/components/Form/Form.test.tsx | 12 +- .../Form/__snapshots__/Form.test.tsx.snap | 256 ++++++--- .../src/components/Header/Header.test.tsx | 8 +- .../Header/__snapshots__/Header.test.tsx.snap | 286 ++++++---- .../src/components/Header/styled.ts | 2 +- .../components/HeaderMenu/HeaderMenu.test.tsx | 8 +- .../__snapshots__/HeaderMenu.test.tsx.snap | 261 ++++++--- .../src/components/Menus/Menus.test.tsx | 5 +- .../src/components/Menus/index.tsx | 8 +- .../src/components/Message/Message.test.tsx | 4 +- .../__snapshots__/Message.test.tsx.snap | 75 ++- .../src/components/Modal/Modal.test.tsx | 4 +- .../Modal/__snapshots__/Modal.test.tsx.snap | 79 ++- .../src/components/Nav/Nav.test.tsx | 5 +- .../Nav/__snapshots__/Nav.test.tsx.snap | 280 ++++++--- .../src/components/Pagination/index.test.tsx | 8 +- .../src/components/Pagination/index.tsx | 12 +- .../__snapshots__/index.test.tsx.snap | 78 +++ .../RootLayout/__tests__/index.test.tsx | 19 + .../__snapshots__/index.test.tsx.snap | 62 ++ .../RouteProtected/__tests__/index.test.tsx | 23 + .../src/components/Search/Search.test.tsx | 2 +- .../src/components/Select/Select.test.tsx | 8 +- .../Select/__snapshots__/Select.test.tsx.snap | 110 +++- .../src/components/Select/index.tsx | 8 +- .../src/components/Sidebar/Sidebar.test.tsx | 28 +- .../__snapshots__/Sidebar.test.tsx.snap | 302 +++++++--- .../src/components/SortBy/SortBy.test.tsx | 1 + .../SortBy/__snapshots__/SortBy.test.tsx.snap | 4 - .../src/components/Table/Table.test.tsx | 11 +- .../Table/__snapshots__/Table.test.tsx.snap | 193 +++++-- .../src/components/Toast/Toast.test.tsx | 4 +- .../Toast/__snapshots__/Toast.test.tsx.snap | 82 ++- hotel-management/src/constants/commons.ts | 8 +- .../src/constants/formValidateMessage.ts | 4 +- hotel-management/src/constants/path.ts | 23 +- .../src/contexts/UserRoomAvailableContext.ts | 96 ++-- .../userRoomAvailableContext.test.tsx | 3 + .../src/helpers/__tests__/helpers.test.ts | 14 +- hotel-management/src/helpers/helper.ts | 10 +- .../src/hooks/__tests__/rooms.test.tsx | 55 +- .../src/hooks/__tests__/useDebounce.test.tsx | 3 +- .../hooks/__tests__/useOutsideClick.test.tsx | 5 - .../src/hooks/__tests__/users.test.tsx | 21 +- .../__tests__/useAccount.test.ts | 16 +- .../__tests__/useLogin.test.tsx | 73 +++ .../__tests__/useLogout.test.tsx | 65 +++ .../__tests__/useUpdateAccount.test.tsx | 69 +++ .../src/hooks/authentication/useLogin.ts | 14 +- .../bookings/__tests__/useBookings.test.tsx | 148 +++++ .../bookings/__tests__/useCheckout.test.tsx | 104 ++++ .../__tests__/useCreateBooking.test.tsx | 94 +++ .../__tests__/useUpdateBooking.test.tsx | 95 +++ .../src/hooks/bookings/useBookings.ts | 6 +- .../src/hooks/bookings/useCheckout.ts | 6 +- .../src/hooks/bookings/useCreateBooking.ts | 6 +- .../src/hooks/bookings/useUpdateBooking.ts | 6 +- .../rooms/__tests__/useCreateRoom.test.tsx | 92 +++ .../hooks/rooms/__tests__/useRooms.test.tsx | 149 +++++ .../__tests__/useSetIsDeleteRoom.test.tsx | 93 +++ .../rooms/__tests__/useUpdateRoom.test.tsx | 93 +++ .../src/hooks/rooms/useCreateRoom.ts | 6 +- hotel-management/src/hooks/rooms/useRooms.ts | 6 +- .../src/hooks/rooms/useSetIsDeleteRoom.ts | 8 +- .../users/__tests__/useCreateUser.test.tsx | 93 +++ .../__tests__/useSetIsDeleteUser.test.tsx | 92 +++ .../users/__tests__/useUpdateUser.test.tsx | 93 +++ .../hooks/users/__tests__/useUsers.test.tsx | 149 +++++ .../src/hooks/users/useCreateUser.ts | 6 +- .../src/hooks/users/useSetIsDeleteUser.ts | 6 +- .../src/hooks/users/useUpdateUser.ts | 6 +- hotel-management/src/hooks/users/useUsers.ts | 10 +- .../__tests__/AccountInforForm.test.tsx | 68 +++ .../__tests__/AccountPasswordForm.test.tsx | 67 +++ .../AccountInforForm.test.tsx.snap | 170 ++++++ .../AccountPasswordForm.test.tsx.snap | 168 ++++++ .../__snapshots__/index.test.tsx.snap | 326 +++++++++++ .../pages/Account/__tests__/index.test.tsx | 18 + .../src/pages/Booking/BookingForm.tsx | 1 - .../Booking/__tests__/BookingForm.test.tsx | 115 ++++ .../Booking/__tests__/BookingRow.test.tsx | 37 ++ .../Booking/__tests__/BookingTable.test.tsx | 22 + .../__snapshots__/BookingForm.test.tsx.snap | 346 +++++++++++ .../__snapshots__/BookingRow.test.tsx.snap | 218 +++++++ .../__snapshots__/BookingTable.test.tsx.snap | 96 ++++ .../__snapshots__/index.test.tsx.snap | 136 +++++ .../pages/Booking/__tests__/index.test.tsx | 22 + .../src/pages/Login/LoginForm.tsx | 6 +- .../pages/Login/__tests__/LoginForm.test.tsx | 63 ++ .../__snapshots__/LoginForm.test.tsx.snap | 166 ++++++ .../__snapshots__/index.test.tsx.snap | 194 +++++++ .../src/pages/Login/__tests__/index.test.tsx | 20 + .../src/pages/NotFound/NotFound.tsx | 21 - .../pages/NotFound/__tests__/index.test.tsx | 28 + hotel-management/src/pages/NotFound/index.tsx | 42 +- hotel-management/src/pages/NotFound/styled.ts | 33 ++ hotel-management/src/pages/Room/RoomForm.tsx | 3 +- .../pages/Room/__tests__/RoomForm.test.tsx | 118 ++++ .../src/pages/Room/__tests__/RoomRow.test.tsx | 29 + .../pages/Room/__tests__/RoomTable.test.tsx | 22 + .../__snapshots__/RoomForm.test.tsx.snap | 184 ++++++ .../__snapshots__/RoomRow.test.tsx.snap | 150 +++++ .../__snapshots__/RoomTable.test.tsx.snap | 166 ++++++ .../__snapshots__/index.test.tsx.snap | 206 +++++++ .../src/pages/Room/__tests__/index.test.tsx | 22 + hotel-management/src/pages/User/UserForm.tsx | 8 +- hotel-management/src/pages/User/UserRow.tsx | 11 +- hotel-management/src/pages/User/UserTable.tsx | 2 +- .../pages/User/__tests__/UserForm.test.tsx | 74 ++- .../src/pages/User/__tests__/UserRow.test.tsx | 4 +- .../pages/User/__tests__/UserTable.test.tsx | 4 +- .../__snapshots__/UserRow.test.tsx.snap | 191 +++++-- .../__snapshots__/UserTable.test.tsx.snap | 215 +++++-- .../__snapshots__/index.test.tsx.snap | 264 ++++++--- .../src/pages/User/__tests__/index.test.tsx | 4 +- hotel-management/src/pages/User/index.tsx | 6 +- .../__tests__/authenticationService.test.ts | 152 +++++ .../services/__tests__/bookingService.test.ts | 230 ++++++++ .../services/__tests__/roomService.test.ts | 355 +++++++++--- .../services/__tests__/userService.test.ts | 280 +++++++-- hotel-management/src/services/userServices.ts | 2 - hotel-management/src/types/supabase.ts | 242 ++++---- 135 files changed, 8702 insertions(+), 1491 deletions(-) create mode 100644 hotel-management/src/components/RootLayout/__tests__/__snapshots__/index.test.tsx.snap create mode 100644 hotel-management/src/components/RootLayout/__tests__/index.test.tsx create mode 100644 hotel-management/src/components/RouteProtected/__tests__/__snapshots__/index.test.tsx.snap create mode 100644 hotel-management/src/components/RouteProtected/__tests__/index.test.tsx create mode 100644 hotel-management/src/hooks/authentication/__tests__/useLogin.test.tsx create mode 100644 hotel-management/src/hooks/authentication/__tests__/useLogout.test.tsx create mode 100644 hotel-management/src/hooks/authentication/__tests__/useUpdateAccount.test.tsx create mode 100644 hotel-management/src/hooks/bookings/__tests__/useBookings.test.tsx create mode 100644 hotel-management/src/hooks/bookings/__tests__/useCheckout.test.tsx create mode 100644 hotel-management/src/hooks/bookings/__tests__/useCreateBooking.test.tsx create mode 100644 hotel-management/src/hooks/bookings/__tests__/useUpdateBooking.test.tsx create mode 100644 hotel-management/src/hooks/rooms/__tests__/useCreateRoom.test.tsx create mode 100644 hotel-management/src/hooks/rooms/__tests__/useRooms.test.tsx create mode 100644 hotel-management/src/hooks/rooms/__tests__/useSetIsDeleteRoom.test.tsx create mode 100644 hotel-management/src/hooks/rooms/__tests__/useUpdateRoom.test.tsx create mode 100644 hotel-management/src/hooks/users/__tests__/useCreateUser.test.tsx create mode 100644 hotel-management/src/hooks/users/__tests__/useSetIsDeleteUser.test.tsx create mode 100644 hotel-management/src/hooks/users/__tests__/useUpdateUser.test.tsx create mode 100644 hotel-management/src/hooks/users/__tests__/useUsers.test.tsx create mode 100644 hotel-management/src/pages/Account/__tests__/AccountInforForm.test.tsx create mode 100644 hotel-management/src/pages/Account/__tests__/AccountPasswordForm.test.tsx create mode 100644 hotel-management/src/pages/Account/__tests__/__snapshots__/AccountInforForm.test.tsx.snap create mode 100644 hotel-management/src/pages/Account/__tests__/__snapshots__/AccountPasswordForm.test.tsx.snap create mode 100644 hotel-management/src/pages/Account/__tests__/__snapshots__/index.test.tsx.snap create mode 100644 hotel-management/src/pages/Account/__tests__/index.test.tsx create mode 100644 hotel-management/src/pages/Booking/__tests__/BookingForm.test.tsx create mode 100644 hotel-management/src/pages/Booking/__tests__/BookingRow.test.tsx create mode 100644 hotel-management/src/pages/Booking/__tests__/BookingTable.test.tsx create mode 100644 hotel-management/src/pages/Booking/__tests__/__snapshots__/BookingForm.test.tsx.snap create mode 100644 hotel-management/src/pages/Booking/__tests__/__snapshots__/BookingRow.test.tsx.snap create mode 100644 hotel-management/src/pages/Booking/__tests__/__snapshots__/BookingTable.test.tsx.snap create mode 100644 hotel-management/src/pages/Booking/__tests__/__snapshots__/index.test.tsx.snap create mode 100644 hotel-management/src/pages/Booking/__tests__/index.test.tsx create mode 100644 hotel-management/src/pages/Login/__tests__/LoginForm.test.tsx create mode 100644 hotel-management/src/pages/Login/__tests__/__snapshots__/LoginForm.test.tsx.snap create mode 100644 hotel-management/src/pages/Login/__tests__/__snapshots__/index.test.tsx.snap create mode 100644 hotel-management/src/pages/Login/__tests__/index.test.tsx delete mode 100644 hotel-management/src/pages/NotFound/NotFound.tsx create mode 100644 hotel-management/src/pages/NotFound/__tests__/index.test.tsx create mode 100644 hotel-management/src/pages/NotFound/styled.ts create mode 100644 hotel-management/src/pages/Room/__tests__/RoomForm.test.tsx create mode 100644 hotel-management/src/pages/Room/__tests__/RoomRow.test.tsx create mode 100644 hotel-management/src/pages/Room/__tests__/RoomTable.test.tsx create mode 100644 hotel-management/src/pages/Room/__tests__/__snapshots__/RoomForm.test.tsx.snap create mode 100644 hotel-management/src/pages/Room/__tests__/__snapshots__/RoomRow.test.tsx.snap create mode 100644 hotel-management/src/pages/Room/__tests__/__snapshots__/RoomTable.test.tsx.snap create mode 100644 hotel-management/src/pages/Room/__tests__/__snapshots__/index.test.tsx.snap create mode 100644 hotel-management/src/pages/Room/__tests__/index.test.tsx create mode 100644 hotel-management/src/services/__tests__/authenticationService.test.ts create mode 100644 hotel-management/src/services/__tests__/bookingService.test.ts diff --git a/hotel-management/package.json b/hotel-management/package.json index 2e05cd6..9c8d398 100644 --- a/hotel-management/package.json +++ b/hotel-management/package.json @@ -19,14 +19,12 @@ "@supabase/supabase-js": "^2.38.4", "@tanstack/react-query": "^5.8.4", "@tanstack/react-query-devtools": "^5.8.4", - "@types/react-test-renderer": "^18.0.6", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.47.0", "react-hot-toast": "^2.4.1", "react-icons": "^4.11.0", "react-router-dom": "^6.17.0", - "react-test-renderer": "^18.2.0", "styled-components": "^6.1.0" }, "devDependencies": { diff --git a/hotel-management/pnpm-lock.yaml b/hotel-management/pnpm-lock.yaml index 1ea06fe..72ff2fd 100644 --- a/hotel-management/pnpm-lock.yaml +++ b/hotel-management/pnpm-lock.yaml @@ -17,9 +17,6 @@ dependencies: '@tanstack/react-query-devtools': specifier: ^5.8.4 version: 5.8.4(@tanstack/react-query@5.8.4)(react-dom@18.2.0)(react@18.2.0) - '@types/react-test-renderer': - specifier: ^18.0.6 - version: 18.0.6 react: specifier: ^18.2.0 version: 18.2.0 @@ -38,9 +35,6 @@ dependencies: react-router-dom: specifier: ^6.17.0 version: 6.17.0(react-dom@18.2.0)(react@18.2.0) - react-test-renderer: - specifier: ^18.2.0 - version: 18.2.0(react@18.2.0) styled-components: specifier: ^6.1.0 version: 6.1.0(react-dom@18.2.0)(react@18.2.0) @@ -1342,6 +1336,7 @@ packages: /@types/prop-types@15.7.9: resolution: {integrity: sha512-n1yyPsugYNSmHgxDFjicaI2+gCNjsBck8UX9kuofAKlc0h1bL+20oSF72KeNaW2DUlesbEVCFgyV2dPGTiY42g==} + dev: true /@types/react-dom@18.2.14: resolution: {integrity: sha512-V835xgdSVmyQmI1KLV2BEIUgqEuinxp9O4G6g3FqO/SqLac049E53aysv0oEFD2kHfejeKU+ZqL2bcFWj9gLAQ==} @@ -1349,21 +1344,17 @@ packages: '@types/react': 18.2.29 dev: true - /@types/react-test-renderer@18.0.6: - resolution: {integrity: sha512-O2JT1J3/v/NaYHYmPf2DXBSqUGmp6iwhFPicES6Pc1Y90B9Qgu99mmaBGqfZFpVuXLzF/pNJB4K9ySL3iqFeXA==} - dependencies: - '@types/react': 18.2.29 - dev: false - /@types/react@18.2.29: resolution: {integrity: sha512-Z+ZrIRocWtdD70j45izShRwDuiB4JZqDegqMFW/I8aG5DxxLKOzVNoq62UIO82v9bdgi+DO1jvsb9sTEZUSm+Q==} dependencies: '@types/prop-types': 15.7.9 '@types/scheduler': 0.16.5 csstype: 3.1.2 + dev: true /@types/scheduler@0.16.5: resolution: {integrity: sha512-s/FPdYRmZR8SjLWGMCuax7r3qCWQw9QKHzXVukAuuIJkXkDRwp+Pu5LMIVFi0Fxbav35WURicYr8u1QsoybnQw==} + dev: true /@types/semver@7.5.3: resolution: {integrity: sha512-OxepLK9EuNEIPxWNME+C6WwbRAOOI2o2BaQEGzz5Lu2e4Z5eDnEo+/aVEDMIXywoJitJ7xWd641wrGLZdtwRyw==} @@ -3738,11 +3729,6 @@ packages: resolution: {integrity: sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ==} dev: true - /object-assign@4.1.1: - resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} - engines: {node: '>=0.10.0'} - dev: false - /object-inspect@1.13.1: resolution: {integrity: sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==} dev: true @@ -4005,6 +3991,7 @@ packages: /react-is@18.2.0: resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} + dev: true /react-refresh@0.14.0: resolution: {integrity: sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==} @@ -4034,27 +4021,6 @@ packages: react: 18.2.0 dev: false - /react-shallow-renderer@16.15.0(react@18.2.0): - resolution: {integrity: sha512-oScf2FqQ9LFVQgA73vr86xl2NaOIX73rh+YFqcOp68CWj56tSfgtGKrEbyhCj0rSijyG9M1CYprTh39fBi5hzA==} - peerDependencies: - react: ^16.0.0 || ^17.0.0 || ^18.0.0 - dependencies: - object-assign: 4.1.1 - react: 18.2.0 - react-is: 18.2.0 - dev: false - - /react-test-renderer@18.2.0(react@18.2.0): - resolution: {integrity: sha512-JWD+aQ0lh2gvh4NM3bBM42Kx+XybOxCpgYK7F8ugAlpaTSnWsX+39Z4XkOykGZAHrjwwTZT3x3KxswVWxHPUqA==} - peerDependencies: - react: ^18.2.0 - dependencies: - react: 18.2.0 - react-is: 18.2.0 - react-shallow-renderer: 16.15.0(react@18.2.0) - scheduler: 0.23.0 - dev: false - /react@18.2.0: resolution: {integrity: sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==} engines: {node: '>=0.10.0'} diff --git a/hotel-management/src/App.test.tsx b/hotel-management/src/App.test.tsx index ec995a5..761b4f7 100644 --- a/hotel-management/src/App.test.tsx +++ b/hotel-management/src/App.test.tsx @@ -1,6 +1,10 @@ import { render, act, RenderResult } from '@testing-library/react'; + +// Services import * as userServices from '@service/userServices'; import * as roomServices from '@service/roomServices'; + +// Components import App from './App'; jest.mock('@service/userServices'); diff --git a/hotel-management/src/App.tsx b/hotel-management/src/App.tsx index f650215..534dbb3 100644 --- a/hotel-management/src/App.tsx +++ b/hotel-management/src/App.tsx @@ -14,7 +14,7 @@ import RootLayout from '@component/RootLayout'; import User from './pages/User'; import Booking from './pages/Booking'; import Room from './pages/Room'; -import NotFound from './pages/NotFound/NotFound'; +import NotFound from './pages/NotFound'; import Login from '@page/Login'; import Account from '@page/Account'; diff --git a/hotel-management/src/__snapshots__/App.test.tsx.snap b/hotel-management/src/__snapshots__/App.test.tsx.snap index 5cbca46..f64b3ec 100644 --- a/hotel-management/src/__snapshots__/App.test.tsx.snap +++ b/hotel-management/src/__snapshots__/App.test.tsx.snap @@ -9,7 +9,7 @@ exports[`App should render correctly 1`] = ` class="sc-jrsKJM iDdaat" >
    { const queryClient = new QueryClient(); - const wrapper = renderer.create( + const wrapper = render( diff --git a/hotel-management/src/components/AppLayout/__snapshots__/AppLayout.test.tsx.snap b/hotel-management/src/components/AppLayout/__snapshots__/AppLayout.test.tsx.snap index a1bf590..45eb3ab 100644 --- a/hotel-management/src/components/AppLayout/__snapshots__/AppLayout.test.tsx.snap +++ b/hotel-management/src/components/AppLayout/__snapshots__/AppLayout.test.tsx.snap @@ -1,208 +1,360 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`AppLayout Should render correctly 1`] = ` -
    -
    -

    - Hi, - ! -

    -
      -
    • - -
    • -
    • - +
    • +
    • + +
    • +
    +
    +
  • - - - +
    + + + , + "container":
    + + + + + + + Booking + + + + + + User + + + + + + + + Room + + + + +
    +
    + , + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} `; diff --git a/hotel-management/src/components/AppLayout/styled.ts b/hotel-management/src/components/AppLayout/styled.ts index 90bbd79..364793b 100644 --- a/hotel-management/src/components/AppLayout/styled.ts +++ b/hotel-management/src/components/AppLayout/styled.ts @@ -4,7 +4,7 @@ const StyledAppLayout = styled.div` display: grid; grid-template-columns: 300px 1fr; grid-template-rows: auto 1fr; - + height: 100vh; `; diff --git a/hotel-management/src/components/ButtonIcon/ButtonIcon.test.tsx b/hotel-management/src/components/ButtonIcon/ButtonIcon.test.tsx index d656e68..2ba19a9 100644 --- a/hotel-management/src/components/ButtonIcon/ButtonIcon.test.tsx +++ b/hotel-management/src/components/ButtonIcon/ButtonIcon.test.tsx @@ -1,11 +1,11 @@ -import renderer from 'react-test-renderer'; - -// Components -import ButtonIcon from '.'; import { HiOutlineLogout } from 'react-icons/hi'; +// Components +import { render } from '@testing-library/react'; +import ButtonIcon from '.'; + describe('ButtonIcon', () => { - const wrapper = renderer.create( + const wrapper = render( } diff --git a/hotel-management/src/components/ButtonIcon/__snapshots__/ButtonIcon.test.tsx.snap b/hotel-management/src/components/ButtonIcon/__snapshots__/ButtonIcon.test.tsx.snap index c125584..12e3a40 100644 --- a/hotel-management/src/components/ButtonIcon/__snapshots__/ButtonIcon.test.tsx.snap +++ b/hotel-management/src/components/ButtonIcon/__snapshots__/ButtonIcon.test.tsx.snap @@ -1,44 +1,110 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ButtonIcon Should render correctly 1`] = ` - +{ + "asFragment": [Function], + "baseElement": +
    + +
    + , + "container":
    + +
    , + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} `; diff --git a/hotel-management/src/components/ConfirmMessage/ConfirmMessage.test.tsx b/hotel-management/src/components/ConfirmMessage/ConfirmMessage.test.tsx index e389c7a..38054eb 100644 --- a/hotel-management/src/components/ConfirmMessage/ConfirmMessage.test.tsx +++ b/hotel-management/src/components/ConfirmMessage/ConfirmMessage.test.tsx @@ -1,6 +1,7 @@ +import { RenderResult, fireEvent, render } from '@testing-library/react'; + // Components import ConfirmMessage from '.'; -import { RenderResult, fireEvent, render } from '@testing-library/react'; describe('ConfirmMessage testing snapshot', () => { const message = 'Hello World!'; diff --git a/hotel-management/src/components/Form/Form.test.tsx b/hotel-management/src/components/Form/Form.test.tsx index 7e248e6..783d197 100644 --- a/hotel-management/src/components/Form/Form.test.tsx +++ b/hotel-management/src/components/Form/Form.test.tsx @@ -1,7 +1,9 @@ -import renderer from 'react-test-renderer'; +import { render } from '@testing-library/react'; // Components import Form from '.'; + +// Styled import Input from '@commonStyle/Input'; describe('Form ', () => { @@ -10,7 +12,7 @@ describe('Form ', () => { const handleOnSubmit = jest.fn(); const handleOnClick = jest.fn(); - const wrapper = renderer.create( + const wrapper = render(
    @@ -24,7 +26,11 @@ describe('Form ', () => { Confirm - + Close diff --git a/hotel-management/src/components/Form/__snapshots__/Form.test.tsx.snap b/hotel-management/src/components/Form/__snapshots__/Form.test.tsx.snap index b3c34ce..4653096 100644 --- a/hotel-management/src/components/Form/__snapshots__/Form.test.tsx.snap +++ b/hotel-management/src/components/Form/__snapshots__/Form.test.tsx.snap @@ -1,74 +1,200 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Form Should render correctly 1`] = ` - -
    - +{ + "asFragment": [Function], + "baseElement":
    - -

    - This is error message -

    +
    + +
    + +

    + This is error message +

    +
    +
    +
    + +
    + +

    + This is error message +

    +
    +
    +
    + + +
    +
    -
    -
    -
    +
    + +
    + +

    + This is error message +

    +
    +
    +
    + + +
    + + , + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} `; diff --git a/hotel-management/src/components/Header/Header.test.tsx b/hotel-management/src/components/Header/Header.test.tsx index 372a9d3..bb3d89a 100644 --- a/hotel-management/src/components/Header/Header.test.tsx +++ b/hotel-management/src/components/Header/Header.test.tsx @@ -1,14 +1,14 @@ -import renderer from 'react-test-renderer'; +import { render } from '@testing-library/react'; +import { BrowserRouter } from 'react-router-dom'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; // Components import Header from '.'; -import { BrowserRouter } from 'react-router-dom'; -import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; describe('Header', () => { const queryClient = new QueryClient(); - const wrapper = renderer.create( + const wrapper = render(
    diff --git a/hotel-management/src/components/Header/__snapshots__/Header.test.tsx.snap b/hotel-management/src/components/Header/__snapshots__/Header.test.tsx.snap index 7fec964..656178a 100644 --- a/hotel-management/src/components/Header/__snapshots__/Header.test.tsx.snap +++ b/hotel-management/src/components/Header/__snapshots__/Header.test.tsx.snap @@ -1,106 +1,194 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Header Should render correctly 1`] = ` -
    -

    - Hi, - Nezumi - ! -

    -
      -
    • - -
    • -
    • - +
    • +
    • + +
    • +
    +
    + + , + "container":
    +
    +

    + Hi, + Nezumi + ! +

    +
      - - - - - -
    -
    +
  • + +
  • +
  • + +
  • + +
    + , + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} `; diff --git a/hotel-management/src/components/Header/styled.ts b/hotel-management/src/components/Header/styled.ts index 9ba8124..fcb68b3 100644 --- a/hotel-management/src/components/Header/styled.ts +++ b/hotel-management/src/components/Header/styled.ts @@ -2,7 +2,7 @@ import styled from 'styled-components'; const StyledHeader = styled.header` border-bottom: 1px solid var(--border-color); - + padding: 20px 40px; display: flex; diff --git a/hotel-management/src/components/HeaderMenu/HeaderMenu.test.tsx b/hotel-management/src/components/HeaderMenu/HeaderMenu.test.tsx index cafb5fc..8748ebb 100644 --- a/hotel-management/src/components/HeaderMenu/HeaderMenu.test.tsx +++ b/hotel-management/src/components/HeaderMenu/HeaderMenu.test.tsx @@ -1,14 +1,14 @@ -import renderer from 'react-test-renderer'; +import { BrowserRouter } from 'react-router-dom'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { render } from '@testing-library/react'; // Components import HeaderMenu from '.'; -import { BrowserRouter } from 'react-router-dom'; -import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; describe('HeaderMenu', () => { const queryClient = new QueryClient(); - const wrapper = renderer.create( + const wrapper = render( diff --git a/hotel-management/src/components/HeaderMenu/__snapshots__/HeaderMenu.test.tsx.snap b/hotel-management/src/components/HeaderMenu/__snapshots__/HeaderMenu.test.tsx.snap index 9740145..c88ef2e 100644 --- a/hotel-management/src/components/HeaderMenu/__snapshots__/HeaderMenu.test.tsx.snap +++ b/hotel-management/src/components/HeaderMenu/__snapshots__/HeaderMenu.test.tsx.snap @@ -1,97 +1,176 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`HeaderMenu Should render correctly 1`] = ` -
      -
    • - -
    • -
    • - +
    • +
    • + +
    • +
    + + , + "container":
    +
      - - - - - -
    +
  • + +
  • +
  • + +
  • + +
    , + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} `; diff --git a/hotel-management/src/components/Menus/Menus.test.tsx b/hotel-management/src/components/Menus/Menus.test.tsx index 781e901..90fd77a 100644 --- a/hotel-management/src/components/Menus/Menus.test.tsx +++ b/hotel-management/src/components/Menus/Menus.test.tsx @@ -1,8 +1,9 @@ -// Components -import Menus from '.'; import { RiEditBoxFill, RiDeleteBin2Line } from 'react-icons/ri'; import { RenderResult, fireEvent, render } from '@testing-library/react'; +// Components +import Menus from '.'; + describe('Menus', () => { const id = '123'; const handleOnClick = jest.fn(); diff --git a/hotel-management/src/components/Menus/index.tsx b/hotel-management/src/components/Menus/index.tsx index 70bf25f..b6e1909 100644 --- a/hotel-management/src/components/Menus/index.tsx +++ b/hotel-management/src/components/Menus/index.tsx @@ -2,13 +2,17 @@ import { MouseEvent, ReactNode, useContext, useState } from 'react'; // Components import { HiEllipsisVertical } from 'react-icons/hi2'; +import ButtonIcon from '@component/ButtonIcon'; // Hooks import { useOutsideClick } from '@hook/useOutsideClick'; -import ButtonIcon from '@component/ButtonIcon'; // Styled -import { StyledMenu, StyledList, StyledToggle } from './styled'; +import { + StyledMenu, + StyledList, + StyledToggle +} from './styled'; // Contexts import MenusContext from '@context/MenuContext'; diff --git a/hotel-management/src/components/Message/Message.test.tsx b/hotel-management/src/components/Message/Message.test.tsx index 0aa2d76..660b276 100644 --- a/hotel-management/src/components/Message/Message.test.tsx +++ b/hotel-management/src/components/Message/Message.test.tsx @@ -1,10 +1,10 @@ -import renderer from 'react-test-renderer'; +import { render } from '@testing-library/react'; // Components import Message from '.'; describe('Message', () => { - const wrapper = renderer.create(This is a message!); + const wrapper = render(This is a message!); test('Should render correctly', () => { expect(wrapper).toMatchSnapshot(); diff --git a/hotel-management/src/components/Message/__snapshots__/Message.test.tsx.snap b/hotel-management/src/components/Message/__snapshots__/Message.test.tsx.snap index b817e31..b53b60e 100644 --- a/hotel-management/src/components/Message/__snapshots__/Message.test.tsx.snap +++ b/hotel-management/src/components/Message/__snapshots__/Message.test.tsx.snap @@ -1,9 +1,74 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Message Should render correctly 1`] = ` -

    - This is a message! -

    +{ + "asFragment": [Function], + "baseElement": +
    +

    + This is a message! +

    +
    + , + "container":
    +

    + This is a message! +

    +
    , + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} `; diff --git a/hotel-management/src/components/Modal/Modal.test.tsx b/hotel-management/src/components/Modal/Modal.test.tsx index 7e17f35..5c43801 100644 --- a/hotel-management/src/components/Modal/Modal.test.tsx +++ b/hotel-management/src/components/Modal/Modal.test.tsx @@ -1,11 +1,11 @@ -import renderer from 'react-test-renderer'; +import { render } from '@testing-library/react'; // Components import Modal from '.'; import Button from '@commonStyle/Button'; describe('Modal', () => { - const wrapper = renderer.create( + const wrapper = render( - Add room - +{ + "asFragment": [Function], + "baseElement": +
    + +
    + , + "container":
    + +
    , + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} `; diff --git a/hotel-management/src/components/Nav/Nav.test.tsx b/hotel-management/src/components/Nav/Nav.test.tsx index 6436c79..7747d44 100644 --- a/hotel-management/src/components/Nav/Nav.test.tsx +++ b/hotel-management/src/components/Nav/Nav.test.tsx @@ -1,11 +1,12 @@ -import renderer from 'react-test-renderer'; + +import { render } from '@testing-library/react'; import { BrowserRouter } from 'react-router-dom'; // Components import Nav from '.'; describe('Nav', () => { - const wrapper = renderer.create( + const wrapper = render( + + , + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} `; diff --git a/hotel-management/src/components/SortBy/SortBy.test.tsx b/hotel-management/src/components/SortBy/SortBy.test.tsx index 28b6454..9c04095 100644 --- a/hotel-management/src/components/SortBy/SortBy.test.tsx +++ b/hotel-management/src/components/SortBy/SortBy.test.tsx @@ -1,6 +1,7 @@ import { BrowserRouter } from 'react-router-dom'; import { useState } from 'react'; import { render, fireEvent, RenderResult } from '@testing-library/react'; + // Components import SortBy from '.'; diff --git a/hotel-management/src/components/SortBy/__snapshots__/SortBy.test.tsx.snap b/hotel-management/src/components/SortBy/__snapshots__/SortBy.test.tsx.snap index 40bcf6f..2fbdfbe 100644 --- a/hotel-management/src/components/SortBy/__snapshots__/SortBy.test.tsx.snap +++ b/hotel-management/src/components/SortBy/__snapshots__/SortBy.test.tsx.snap @@ -10,13 +10,11 @@ exports[`SortBy Should render correctly 1`] = ` class="sc-bdnyFh hPOEsG" >