Update code and message test case

This commit is contained in:
2023-11-26 13:39:11 +07:00
parent a05ec603e5
commit 77b230dc5f
36 changed files with 66 additions and 72 deletions
+1
View File
@@ -12,6 +12,7 @@ dist
dist-ssr
*.local
.vscode
coverage
src/db.json
+3
View File
@@ -10,6 +10,9 @@
"preview": "vite preview",
"test": "jest"
},
"coverageReporters": [
"html"
],
"dependencies": {
"@emotion/is-prop-valid": "^1.2.1",
"@supabase/supabase-js": "^2.38.4",
@@ -4,14 +4,14 @@ import { BrowserRouter } from 'react-router-dom';
// Components
import AppLayout from '.';
describe('AppLayout testing snapshot', () => {
describe('AppLayout', () => {
const wrapper = renderer.create(
<BrowserRouter>
<AppLayout />
</BrowserRouter>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`AppLayout testing snapshot render 1`] = `
exports[`AppLayout Should render correctly 1`] = `
<div
className="sc-iCoHzw jFLeHb"
>
@@ -4,7 +4,7 @@ import renderer from 'react-test-renderer';
import ButtonIcon from '.';
import { HiOutlineLogout } from 'react-icons/hi';
describe('ButtonIcon testing snapshot', () => {
describe('ButtonIcon', () => {
const wrapper = renderer.create(
<ButtonIcon
aria-label="Logout"
@@ -13,7 +13,7 @@ describe('ButtonIcon testing snapshot', () => {
/>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ButtonIcon testing snapshot render 1`] = `
exports[`ButtonIcon Should render correctly 1`] = `
<button
className="sc-bdnyFh bxHnoO"
iconStyle={
@@ -3,12 +3,10 @@ import renderer from 'react-test-renderer';
// Components
import ConfirmMessage from '.';
describe('ConfirmMessage testing snapshot', () => {
describe('ConfirmMessage', () => {
const isDisable = true;
const message = 'Hello World!';
const handleOnConfirm = () => {
console.log('Confirm');
};
const handleOnConfirm = jest.fn();
const wrapper = renderer.create(
<ConfirmMessage
@@ -18,7 +16,7 @@ describe('ConfirmMessage testing snapshot', () => {
/>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ConfirmMessage testing snapshot render 1`] = `
exports[`ConfirmMessage Should render correctly 1`] = `
<div
className="sc-bdnyFh dukbvo"
>
@@ -11,7 +11,7 @@ exports[`ConfirmMessage testing snapshot render 1`] = `
<button
className="sc-gtsqUy eZzwwl"
disabled={true}
onClick={[Function]}
onClick={[MockFunction]}
variations="danger"
>
Delete
@@ -7,15 +7,11 @@ import Input from '@commonStyle/Input';
// Styled
import { FormBtn } from '@page/User/styled';
describe('Form testing snapshot', () => {
describe('Form ', () => {
const isDisable = true;
const errorMessage = 'This is error message';
const handleOnSubmit = () => {
console.log('Confirm');
};
const handleOnClick = () => {
console.log('On Click');
};
const handleOnSubmit = jest.fn();
const handleOnClick = jest.fn();
const wrapper = renderer.create(
<Form onSubmit={handleOnSubmit}>
@@ -38,7 +34,7 @@ describe('Form testing snapshot', () => {
</Form>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Form testing snapshot render 1`] = `
exports[`Form Should render correctly 1`] = `
<form
className="sc-bdnyFh bzxSLR"
onSubmit={[Function]}
onSubmit={[MockFunction]}
>
<div
className="sc-dlniIP gZHESL"
@@ -61,7 +61,7 @@ exports[`Form testing snapshot render 1`] = `
</button>
<button
className="sc-gKAaef sc-jrsKJM gbgZUe KLoQf"
onClick={[Function]}
onClick={[MockFunction]}
type="button"
variations="secondary"
>
@@ -3,10 +3,10 @@ import renderer from 'react-test-renderer';
// Components
import Header from '.';
describe('Header testing snapshot', () => {
describe('Header', () => {
const wrapper = renderer.create(<Header accountName="Nezumi" />);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Header testing snapshot render 1`] = `
exports[`Header Should render correctly 1`] = `
<header
className="sc-dlniIP cClxoS"
>
@@ -3,10 +3,10 @@ import renderer from 'react-test-renderer';
// Components
import HeaderMenu from '.';
describe('HeaderMenu testing snapshot', () => {
describe('HeaderMenu', () => {
const wrapper = renderer.create(<HeaderMenu />);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`HeaderMenu testing snapshot render 1`] = `
exports[`HeaderMenu Should render correctly 1`] = `
<ul
className="sc-gtsqUy gOWXQs"
>
@@ -4,11 +4,9 @@ import renderer from 'react-test-renderer';
import Menus from '.';
import { RiEditBoxFill, RiDeleteBin2Line } from 'react-icons/ri';
describe('Menus snapshot testing', () => {
describe('Menus', () => {
const id = '123';
const handleOnClick = () => {
console.log('Click');
};
const handleOnClick = jest.fn();
const wrapper = renderer.create(
<Menus>
@@ -27,7 +25,7 @@ describe('Menus snapshot testing', () => {
</Menus>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Menus snapshot testing render 1`] = `
exports[`Menus Should render correctly 1`] = `
<div
className="sc-bdnyFh cumhtC"
className="sc-gtsqUy lbsvcs"
>
<button
aria-label="Menu item 123"
className="sc-dlniIP jergss"
className="sc-hKFymg cjUckY"
onClick={[Function]}
>
<svg
@@ -3,10 +3,10 @@ import renderer from 'react-test-renderer';
// Components
import Message from '.';
describe('Message testing snapshot', () => {
describe('Message', () => {
const wrapper = renderer.create(<Message>This is a message!</Message>);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Message testing snapshot render 1`] = `
exports[`Message Should render correctly 1`] = `
<p
className="sc-bdnyFh fIKUZt"
>
@@ -4,7 +4,7 @@ import renderer from 'react-test-renderer';
import Modal from '.';
import Button from '@commonStyle/Button';
describe('Modal testing snapshot', () => {
describe('Modal', () => {
const wrapper = renderer.create(
<Modal>
<Modal.Open
@@ -19,7 +19,7 @@ describe('Modal testing snapshot', () => {
</Modal>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Modal testing snapshot render 1`] = `
exports[`Modal Should render correctly 1`] = `
<button
className="sc-eCAqax jeAcqZ"
onClick={[Function]}
@@ -4,14 +4,14 @@ import { BrowserRouter } from 'react-router-dom';
// Components
import Nav from '.';
describe('Nav testing snapshot', () => {
describe('Nav', () => {
const wrapper = renderer.create(
<BrowserRouter>
<Nav />
</BrowserRouter>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Nav testing snapshot render 1`] = `
exports[`Nav Should render correctly 1`] = `
<nav
className="sc-bdnyFh gGCifp"
>
@@ -4,7 +4,7 @@ import { BrowserRouter } from 'react-router-dom';
// Components
import Order from '.';
describe('<Order.test />', () => {
describe('Order', () => {
const options = [
{
value: 'Value 1',
@@ -22,7 +22,7 @@ describe('<Order.test />', () => {
</BrowserRouter>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Order.test /> render 1`] = `
exports[`Order Should render correctly 1`] = `
<div
className="sc-bdnyFh aZFGz"
>
@@ -4,7 +4,7 @@ import { BrowserRouter } from 'react-router-dom';
// Components
import Search from '.';
describe('Search testing snapshot', () => {
describe('Search', () => {
const placeHolder = 'Search placeholder...';
const wrapper = renderer.create(
<BrowserRouter>
@@ -12,7 +12,7 @@ describe('Search testing snapshot', () => {
</BrowserRouter>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Search testing snapshot render 1`] = `
exports[`Search Should render correctly 1`] = `
<input
className="sc-bdnyFh eAgOPb"
onChange={[Function]}
@@ -3,7 +3,7 @@ import renderer from 'react-test-renderer';
// Components
import Select from '.';
describe('Select testing snapshot', () => {
describe('Select', () => {
const options = [
{
label: 'Option 1',
@@ -15,9 +15,7 @@ describe('Select testing snapshot', () => {
}
];
const value = 'Temp value';
const handleOnChange = () => {
console.log('On change');
}
const handleOnChange = jest.fn();
const wrapper = renderer.create(
<Select
@@ -28,7 +26,7 @@ describe('Select testing snapshot', () => {
/>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Select testing snapshot render 1`] = `
exports[`Select Should render correctly 1`] = `
<select
aria-label="Sort"
className="sc-bdnyFh dqXTRP"
onChange={[Function]}
onChange={[MockFunction]}
value="Temp value"
>
<option
@@ -4,14 +4,14 @@ import { BrowserRouter } from 'react-router-dom';
// Components
import Sidebar from '.';
describe('Sidebar testing snapshot', () => {
describe('Sidebar', () => {
const wrapper = renderer.create(
<BrowserRouter>
<Sidebar heading="Hotel Management" />
</BrowserRouter>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Sidebar testing snapshot render 1`] = `
exports[`Sidebar Should render correctly 1`] = `
<aside
className="sc-dlniIP dfcuiS"
>
@@ -4,7 +4,7 @@ import { BrowserRouter } from 'react-router-dom';
// Components
import SortBy from '.';
describe('<SortBy.test />', () => {
describe('SortBy', () => {
const options = [
{
label: 'Option 1',
@@ -21,7 +21,7 @@ describe('<SortBy.test />', () => {
</BrowserRouter>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<SortBy.test /> render 1`] = `
exports[`SortBy Should render correctly 1`] = `
<select
aria-label="Sort"
className="sc-bdnyFh dqXTRP"
@@ -10,7 +10,7 @@ interface ITableRow {
user: IUser;
}
describe('Table testing snapshot', () => {
describe('Table', () => {
const columnName = ['Column 1', 'Column 2'];
const tempUser: IUser[] = [
{
@@ -47,7 +47,7 @@ describe('Table testing snapshot', () => {
</Table>
);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Table testing snapshot render 1`] = `
exports[`Table Should render correctly 1`] = `
<div
className="sc-bdnyFh eEibLN"
>
@@ -3,10 +3,10 @@ import renderer from 'react-test-renderer';
// Components
import Toast from '.';
describe('Toast testing snapshot', () => {
describe('Toast', () => {
const wrapper = renderer.create(<Toast />);
test('render', () => {
test('Should render correctly', () => {
expect(wrapper).toMatchSnapshot();
});
});
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Toast testing snapshot render 1`] = `
exports[`Toast Should render correctly 1`] = `
<div
onMouseEnter={[Function]}
onMouseLeave={[Function]}