setup vite testing and able to run test

This commit is contained in:
Simon
2024-07-02 17:10:07 -04:00
parent 5e9b8ac84e
commit 452416ae18
6 changed files with 943 additions and 77 deletions

View 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()
})
})

View File

@@ -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
View File

@@ -0,0 +1 @@
import '@testing-library/jest-dom'