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