mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-07-23 04:36:52 +00:00
setup vite testing and able to run test
This commit is contained in:
15
src/components/PasswordField/PasswordField.spec.tsx
Normal file
15
src/components/PasswordField/PasswordField.spec.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import {
|
||||
describe,
|
||||
expect,
|
||||
test
|
||||
} from 'vitest';
|
||||
import {render, screen} from '@testing-library/react'
|
||||
import {
|
||||
PasswordField
|
||||
} from './PasswordField'
|
||||
describe('PasswordField', () => {
|
||||
test('it renders', () => {
|
||||
render(<PasswordField />)
|
||||
expect('').toBeFalsy()
|
||||
})
|
||||
})
|
@@ -2,7 +2,8 @@ import { InputAdornment, TextField, TextFieldProps, styled } from "@mui/material
|
||||
import { useState } from 'react'
|
||||
|
||||
export const CustomInput = styled(TextField)({
|
||||
width: "183px", // Adjust the width as needed
|
||||
width: "100%", // Adjust the width as needed
|
||||
maxWidth: "183px",
|
||||
borderRadius: "5px",
|
||||
// backgroundColor: "rgba(30, 30, 32, 1)",
|
||||
outline: "none",
|
||||
@@ -44,12 +45,8 @@ export const CustomInput = styled(TextField)({
|
||||
export const PasswordField: React.FunctionComponent<TextFieldProps> = ({ ...props }) => {
|
||||
const [canViewPassword, setCanViewPassword] = useState(false);
|
||||
return (
|
||||
<div style={{
|
||||
position: 'relative'
|
||||
}}>
|
||||
<CustomInput
|
||||
type={canViewPassword ? 'text' : 'password'}
|
||||
id="standard-adornment-password"
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end" style={{
|
||||
@@ -57,13 +54,11 @@ export const PasswordField: React.FunctionComponent<TextFieldProps> = ({ ...prop
|
||||
}} onClick={() => {
|
||||
setCanViewPassword((prevState) => !prevState)
|
||||
}}>
|
||||
{canViewPassword ? '🙀' : '😸'}
|
||||
{canViewPassword ? <span data-testid="eyes-opened">🙀</span> : <span data-testid="eyes-closed">😸</span>}
|
||||
</InputAdornment>
|
||||
)
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
1
src/test/setup.ts
Normal file
1
src/test/setup.ts
Normal file
@@ -0,0 +1 @@
|
||||
import '@testing-library/jest-dom'
|
Reference in New Issue
Block a user