Skip to content

Commit d17a808

Browse files
committed
refactor: Use Language in tests
1 parent 0455e54 commit d17a808

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

site/src/components/Navbar/UserDropdown.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { screen } from "@testing-library/react"
22
import React from "react"
33
import { render } from "../../test_helpers"
44
import { MockUser } from "../../test_helpers/entities"
5-
import { UserDropdown, UserDropdownProps } from "./UserDropdown"
5+
import { Language, UserDropdown, UserDropdownProps } from "./UserDropdown"
66

77
const renderAndClick = async (props: Partial<UserDropdownProps> = {}) => {
88
render(<UserDropdown user={props.user ?? MockUser} onSignOut={props.onSignOut ?? jest.fn()} />)
@@ -14,9 +14,9 @@ describe("UserDropdown", () => {
1414
describe("when the trigger is clicked", () => {
1515
it("opens the menu", async () => {
1616
await renderAndClick()
17-
expect(screen.getByText(/account/i)).toBeDefined()
18-
expect(screen.getByText(/documentation/i)).toBeDefined()
19-
expect(screen.getByText(/sign out/i)).toBeDefined()
17+
expect(screen.getByText(Language.accountLabel)).toBeDefined()
18+
expect(screen.getByText(Language.docsLabel)).toBeDefined()
19+
expect(screen.getByText(Language.signOutLabel)).toBeDefined()
2020
})
2121
})
2222

@@ -25,7 +25,7 @@ describe("UserDropdown", () => {
2525
it("calls the onSignOut function", async () => {
2626
const onSignOut = jest.fn()
2727
await renderAndClick({ onSignOut })
28-
screen.getByText(/sign out/i).click()
28+
screen.getByText(Language.signOutLabel).click()
2929
expect(onSignOut).toBeCalledTimes(1)
3030
})
3131
})
@@ -34,7 +34,7 @@ describe("UserDropdown", () => {
3434
it("has the correct link for the documentation item", async () => {
3535
await renderAndClick()
3636

37-
const link = screen.getByText(/documentation/i).closest("a")
37+
const link = screen.getByText(Language.docsLabel).closest("a")
3838
if (!link) {
3939
throw new Error("Anchor tag not found for the documentation menu item")
4040
}
@@ -45,7 +45,7 @@ describe("UserDropdown", () => {
4545
it("has the correct link for the account item", async () => {
4646
await renderAndClick()
4747

48-
const link = screen.getByText(/account/i).closest("a")
48+
const link = screen.getByText(Language.accountLabel).closest("a")
4949
if (!link) {
5050
throw new Error("Anchor tag not found for the account menu item")
5151
}

0 commit comments

Comments
 (0)