diff --git a/hotel-management/package.json b/hotel-management/package.json
index 7634a5f..2e05cd6 100644
--- a/hotel-management/package.json
+++ b/hotel-management/package.json
@@ -8,7 +8,8 @@
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
- "test": "jest --coverage"
+ "test-ci": "jest --coverage",
+ "test": "jest --runTestsByPath"
},
"coverageReporters": [
"html"
diff --git a/hotel-management/src/App.test.tsx b/hotel-management/src/App.test.tsx
new file mode 100644
index 0000000..ec995a5
--- /dev/null
+++ b/hotel-management/src/App.test.tsx
@@ -0,0 +1,69 @@
+import { render, act, RenderResult } from '@testing-library/react';
+import * as userServices from '@service/userServices';
+import * as roomServices from '@service/roomServices';
+import App from './App';
+
+jest.mock('@service/userServices');
+jest.mock('@service/roomServices');
+
+describe('App', () => {
+ let wrapper: RenderResult | null = null;
+
+ beforeEach(async () => {
+ await act(async () => {
+ wrapper = render();
+ });
+ });
+
+ test('should render correctly', () => {
+ expect(wrapper).toMatchSnapshot();
+ });
+
+ test('Should init room, user data', async () => {
+ const mockGetUserNotBooked = jest.spyOn(userServices, 'getAllUsers');
+ const mockGetRoomAvailable = jest.spyOn(roomServices, 'getAllRooms');
+
+ mockGetUserNotBooked.mockResolvedValue({
+ data: [
+ {
+ id: 1,
+ name: 'Nezumi',
+ phone: '0324432321',
+ isBooked: true,
+ isDelete: true,
+ },
+ {
+ id: 1,
+ name: 'Loi Phan',
+ phone: '0324432123',
+ isBooked: true,
+ isDelete: true,
+ },
+ ],
+ count: 2,
+ });
+
+ mockGetRoomAvailable.mockResolvedValue({
+ data: [
+ {
+ id: 1,
+ name: 'Room 1',
+ price: 230,
+ status: true,
+ isDelete: true,
+ },
+ {
+ id: 2,
+ name: 'Room 2',
+ price: 242,
+ status: true,
+ isDelete: true
+ },
+ ],
+ count: 2
+ });
+
+ expect(mockGetUserNotBooked).toHaveBeenCalled();
+ expect(mockGetRoomAvailable).toHaveBeenCalled();
+ });
+});
diff --git a/hotel-management/src/__snapshots__/App.test.tsx.snap b/hotel-management/src/__snapshots__/App.test.tsx.snap
new file mode 100644
index 0000000..5cbca46
--- /dev/null
+++ b/hotel-management/src/__snapshots__/App.test.tsx.snap
@@ -0,0 +1,84 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`App 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/AppLayout/AppLayout.test.tsx b/hotel-management/src/components/AppLayout/AppLayout.test.tsx
index 471cd48..6717ed4 100644
--- a/hotel-management/src/components/AppLayout/AppLayout.test.tsx
+++ b/hotel-management/src/components/AppLayout/AppLayout.test.tsx
@@ -3,12 +3,17 @@ import { BrowserRouter } from 'react-router-dom';
// Components
import AppLayout from '.';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
describe('AppLayout', () => {
+ const queryClient = new QueryClient();
+
const wrapper = renderer.create(
-
-
-
+
+
+
+
+
);
test('Should render correctly', () => {
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 6d48dfc..dc7ccf8 100644
--- a/hotel-management/src/components/AppLayout/__snapshots__/AppLayout.test.tsx.snap
+++ b/hotel-management/src/components/AppLayout/__snapshots__/AppLayout.test.tsx.snap
@@ -9,7 +9,6 @@ exports[`AppLayout Should render correctly 1`] = `
>
Hi,
- Admin
!