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', () => { describe('Home', () => {
it('renders a heading', () => { it('renders a heading', () => {
render(<Home />); render(<Home totalNum={0} pagingSize={0} allPages={0} postDatas={[]} />);
const heading = screen.getByText(/hello/i); const heading = screen.getByText(/hello/i);

View File

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

View File

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

View File

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

View File

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

View File

@ -1,13 +1,13 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction // 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 = { type Data = {
name: string name: string;
} };
export default function handler( export default function handler(
req: NextApiRequest, req: NextApiRequest,
res: NextApiResponse<Data> 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 { state, dispatch } = useRUAContext();
const handleInput: ChangeEventHandler<HTMLInputElement> = (e) => { const handleInput: ChangeEventHandler<HTMLInputElement> = (e) => {
dispatch({ type: ActionKind.SETQUERY, playload: e.target.value }); dispatch({ type: ActionKind.SETQUERY, payload: e.target.value });
}; };
return ( return (