我正在尝试在我的 React 应用程序上测试 Info HOC:
const InfoHOC = (HocComponent) => ({ message }) => (
<>
<Tooltip title={message}>
<InfoIcon />
</Tooltip>
{HocComponent}
</>
);
export default InfoHOC;Run Code Online (Sandbox Code Playgroud)
我已经简化了。但由于它使用 Material ui Tooltip 组件,我无法测试鼠标悬停时是否显示消息...
it('should display info message on <div /> mouseover', () => {
const Component = InfoHoc(<div>jest div</div>)({ message: 'jest infoHoc message' });
const { getByTitle, getByDisplayValue } = render(Component);
const icon = getByTitle('jest infoHoc message');
act(() => {
fireEvent(
icon,
new MouseEvent('mouseover', {
bubbles: true,
}),
);
});
expect(getByDisplayValue('jest …Run Code Online (Sandbox Code Playgroud)我正在尝试使用 进行凭据身份验证next-auth。我必须使用自定义登录页面,但我绝对无法让它工作大约一整周。
我有 :
\n// [...nextauth.js]\n\nimport NextAuth from \'next-auth\';\nimport Providers from \'next-auth/providers\';\n\nimport axios from \'@api/axios\';\n\nconst options = {\n providers: [\n Providers.Credentials({\n async authorize(credentials) {\n const { data: user, status } = await axios.post(\'/users/authentication\', credentials);\n\n if (user && status === 200) {\n return user;\n } else {\n throw new Error(\'error message\');\n }\n }\n })\n ],\n pages: {\n signIn: \'/profil/authentication/login\',\n error: \'/profil/authentication/login\'\n },\n session: {\n jwt: true,\n maxAge: 30 * 24 * 60 * 60 // …Run Code Online (Sandbox Code Playgroud)