From 5d5eb1adaf579e7bacf69e8bd8f413c03729a0c5 Mon Sep 17 00:00:00 2001
From: Loi Phan
Date: Sun, 3 Dec 2023 22:22:36 +0700
Subject: [PATCH] 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,
- !
-
-
- -
-
+
+