Fix some little issues

This commit is contained in:
DefectingCat
2022-01-17 22:22:54 +08:00
parent 0a864bdca2
commit df7b83a489
7 changed files with 13 additions and 13 deletions

View File

@ -7,7 +7,7 @@ import Home from 'pages/index';
describe('Home', () => {
it('renders a heading', () => {
render(<Home />);
render(<Home totalNum={0} pagingSize={0} allPages={0} postDatas={[]} />);
const heading = screen.getByText(/hello/i);

View File

@ -25,7 +25,7 @@ const SearchBox: FC = () => {
const handleInput: ChangeEventHandler<HTMLInputElement> = useCallback(
(e) => {
dispatch({ type: ActionKind.SETQUERY, playload: e.target.value });
dispatch({ type: ActionKind.SETQUERY, payload: e.target.value });
},
[dispatch]
);

View File

@ -6,7 +6,7 @@ export enum ActionKind {
type ReducerAction = {
type: ActionKind;
playload: string;
payload: string;
};
type State = {
@ -22,10 +22,10 @@ const initialState: State = {
};
const reducer = (state: State, action: ReducerAction): State => {
const { type, playload } = action;
const { type, payload } = action;
switch (type) {
case ActionKind.SETQUERY:
return { searchQuery: playload };
return { searchQuery: payload };
default:
throw new Error();
}

View File

@ -12,7 +12,7 @@ import RUAStore from '../lib/store';
const H2 = dynamic(() => import('components/MDX/MDXH2'));
// MDX components
const mdxCompoents = {
const mdxComponents = {
h2: H2,
};
@ -38,7 +38,7 @@ function MyApp({ Component, pageProps }: AppPropsWithLayout) {
</Head>
<RUAStore>
<MDXProvider components={mdxCompoents}>
<MDXProvider components={mdxComponents}>
{getLayout(<Component {...pageProps} />)}
</MDXProvider>
</RUAStore>

View File

@ -1,5 +1,5 @@
import AboutMDXLayout from 'layouts/MDXLayout';
import { FiGithub, FiExternalLink } from 'react-icons/fi';
import { FiGithub } from 'react-icons/fi';
import RUALink from 'components/RUA/RUALink';
<AboutMDXLayout title="RUA - About">

View File

@ -1,13 +1,13 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next'
import type { NextApiRequest, NextApiResponse } from 'next';
type Data = {
name: string
}
name: string;
};
export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
res.status(200).json({ name: 'John Doe' })
res.status(200).json({ name: 'xfy!' });
}

View File

@ -11,7 +11,7 @@ const Search = () => {
const { state, dispatch } = useRUAContext();
const handleInput: ChangeEventHandler<HTMLInputElement> = (e) => {
dispatch({ type: ActionKind.SETQUERY, playload: e.target.value });
dispatch({ type: ActionKind.SETQUERY, payload: e.target.value });
};
return (