mirror of
https://github.com/gosticks/web.git
synced 2026-10-06 06:37:07 +00:00
Use another defaultProps method for NavButton
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
@@ -15,10 +15,10 @@ import React, { MouseEventHandler } from "react";
|
||||
export interface NavButtonProps {
|
||||
name: string;
|
||||
icon: string;
|
||||
onClick?: MouseEventHandler;
|
||||
onClick: MouseEventHandler;
|
||||
}
|
||||
|
||||
export default ({ name, icon, onClick = () => {} }: NavButtonProps) => (
|
||||
const NavButton = ({ name, icon, onClick }: NavButtonProps) => (
|
||||
<li className="nav-item">
|
||||
<a
|
||||
href="#"
|
||||
@@ -33,3 +33,9 @@ export default ({ name, icon, onClick = () => {} }: NavButtonProps) => (
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
|
||||
NavButton.defaultProps = {
|
||||
onClick: () => {}
|
||||
};
|
||||
|
||||
export default NavButton;
|
||||
|
||||
@@ -84,7 +84,8 @@ describe("EnableDisable", () => {
|
||||
wrapper
|
||||
.find(NavButton)
|
||||
.at(buttonIndex)
|
||||
.props().onClick!({} as MouseEvent);
|
||||
.props()
|
||||
.onClick({} as MouseEvent);
|
||||
|
||||
// Wait for the setStatus promise to resolve
|
||||
await tick();
|
||||
@@ -128,7 +129,10 @@ describe("EnableDisable", () => {
|
||||
|
||||
wrapper.setState({ processing: true });
|
||||
|
||||
wrapper.find(NavButton).props().onClick!({} as MouseEvent);
|
||||
wrapper
|
||||
.find(NavButton)
|
||||
.props()
|
||||
.onClick({} as MouseEvent);
|
||||
|
||||
expect(setStatus).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -147,7 +151,10 @@ describe("EnableDisable", () => {
|
||||
/>
|
||||
);
|
||||
|
||||
wrapper.find(NavButton).props().onClick!({} as MouseEvent);
|
||||
wrapper
|
||||
.find(NavButton)
|
||||
.props()
|
||||
.onClick({} as MouseEvent);
|
||||
|
||||
wrapper.unmount();
|
||||
|
||||
@@ -168,7 +175,10 @@ describe("EnableDisable", () => {
|
||||
/>
|
||||
);
|
||||
|
||||
wrapper.find(NavButton).props().onClick!({} as MouseEvent);
|
||||
wrapper
|
||||
.find(NavButton)
|
||||
.props()
|
||||
.onClick({} as MouseEvent);
|
||||
|
||||
expect(wrapper.state().processing).toBeTruthy();
|
||||
|
||||
@@ -216,7 +226,8 @@ describe("EnableDisable", () => {
|
||||
wrapper
|
||||
.find(NavButton)
|
||||
.last()
|
||||
.props().onClick!({} as MouseEvent);
|
||||
.props()
|
||||
.onClick({} as MouseEvent);
|
||||
|
||||
expect(wrapper.find(Modal).props().isOpen).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
import React from "react";
|
||||
import React, { MouseEvent } from "react";
|
||||
import { shallow } from "enzyme";
|
||||
import Sidebar, { NavList, PiholeNavDropdown, PiholeNavItem } from "../Sidebar";
|
||||
import api from "../../../util/api";
|
||||
@@ -207,11 +207,7 @@ it("should hide the sidebar on mobile when an item is clicked", () => {
|
||||
document.body.classList.add("sidebar-show");
|
||||
expect(document.body.classList).toContain("sidebar-show");
|
||||
|
||||
// @ts-ignore
|
||||
wrapper
|
||||
.find(NavLink)
|
||||
.props()
|
||||
.onClick();
|
||||
wrapper.find(NavLink).props().onClick!({} as MouseEvent<HTMLAnchorElement>);
|
||||
|
||||
expect(document.body.classList).not.toContain("sidebar-show");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user