Skip to content

Commit 9571ccd

Browse files
committed
style:
1 parent 1f5dc18 commit 9571ccd

File tree

3 files changed

+7
-42
lines changed

3 files changed

+7
-42
lines changed

frontend/tests/components/ui/field.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ describe("Field", (): void => {
140140
</Field>,
141141
)
142142
const label: HTMLElement = screen.getByText("Email")
143-
const requiredIndicator = screen.getByText("*")
143+
const requiredIndicator: HTMLElement = screen.getByText("*")
144144
expect(label).toContainElement(requiredIndicator)
145145
})
146146

frontend/tests/components/ui/password-input.test.tsx

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ vi.mock("@/components/ui/field", () => ({
3030
children,
3131
errorText,
3232
invalid,
33-
}: {
34-
children: ReactElement
35-
errorText?: string
36-
invalid: boolean
37-
}): ReactElement => (
33+
}: { children: ReactElement; errorText?: string; invalid: boolean }): ReactElement => (
3834
<div data-invalid={invalid}>
3935
{children}
4036
{errorText && <span>{errorText}</span>}
@@ -51,13 +47,7 @@ vi.mock("@/components/ui/input-group", () => ({
5147
* @param {ReactElement} [props.endElement] - The element to render at the end.
5248
* @returns {ReactElement} A mocked div representing the InputGroup.
5349
*/
54-
InputGroup: ({
55-
children,
56-
endElement,
57-
}: {
58-
children: ReactElement
59-
endElement?: ReactElement
60-
}): ReactElement => (
50+
InputGroup: ({ children, endElement }: { children: ReactElement; endElement?: ReactElement }): ReactElement => (
6151
<div>
6252
{children}
6353
{endElement}
@@ -84,30 +74,15 @@ vi.mock("@chakra-ui/react", async (importOriginal) => {
8474
any // Using 'any' here is a pragmatic choice for the mock, as the props are a mix of HTML and Chakra-specific ones.
8575
>(function MockChakraIconButton(props, ref): ReactElement {
8676
// Correctly destructure and ignore non-standard props for a native button
87-
const {
88-
aspectRatio,
89-
me,
90-
size,
91-
variant,
92-
height,
93-
color,
94-
children,
95-
...rest // `rest` will now only contain valid HTML button attributes
96-
} = props
97-
77+
const { aspectRatio, me, size, variant, height, color, children, ...rest } = props
9878
return (
9979
<button ref={ref} type="button" {...rest}>
10080
{children}
10181
</button>
10282
)
10383
})
10484
MockChakraIconButton.displayName = "MockChakraIconButton"
105-
106-
return {
107-
...original,
108-
Input: MockChakraInput,
109-
IconButton: MockChakraIconButton,
110-
}
85+
return { ...original, Input: MockChakraInput, IconButton: MockChakraIconButton }
11186
})
11287

11388
// endregion
@@ -120,12 +95,8 @@ describe("PasswordInput", () => {
12095
it("should render the input and toggle type on click", async () => {
12196
const user = userEvent.setup()
12297
render(<PasswordInput name="password" errors={{}} />)
123-
12498
const input = screen.getByPlaceholderText<HTMLInputElement>("password-input")
125-
const toggleButton = screen.getByRole("button", {
126-
name: "Toggle password visibility",
127-
})
128-
99+
const toggleButton = screen.getByRole("button", { name: "Toggle password visibility" })
129100
expect(input.type).toBe("password")
130101
await user.click(toggleButton)
131102
expect(input.type).toBe("text")
@@ -134,9 +105,7 @@ describe("PasswordInput", () => {
134105
})
135106

136107
it("should display an error message when an error is provided", () => {
137-
const errors: FieldErrors<TestForm> = {
138-
password: { type: "required", message: "This field is required" },
139-
}
108+
const errors: FieldErrors<TestForm> = { password: { type: "required", message: "This field is required" } }
140109
render(<PasswordInput name="password" errors={errors} />)
141110
expect(screen.getByText("This field is required")).toBeInTheDocument()
142111
})

frontend/tests/hooks/useAuth.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,10 @@ describe("useAuth", (): void => {
251251
const mockUser: UserPublic = { id: "1", email: "user@example.com" }
252252
mockedLoginApi.mockResolvedValueOnce(mockAccessTokenResponse)
253253
mockedReadMeApi.mockResolvedValueOnce(mockUser)
254-
255254
const { result, rerender } = renderAuthHook()
256-
// Call with the correctly structured mockLoginData
257255
result.current.loginMutation.mutate(mockLoginData)
258-
259256
await waitFor((): void => expect(result.current.loginMutation.isSuccess).toBe(true))
260257
expect(localStorageMock.setItem).toHaveBeenCalledWith("access_token", "mock-jwt-token")
261-
262258
rerender() // Re-render to trigger `currentUser` query if enabled after token is set
263259
await waitFor((): void => expect(result.current.user).toEqual(mockUser))
264260
expect(mockedReadMeApi).toHaveBeenCalledTimes(1)

0 commit comments

Comments
 (0)