Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd17a808

Browse files
committed
refactor: Use Language in tests
1 parent0455e54 commitd17a808

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
importReactfrom"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
constrenderAndClick=async(props:Partial<UserDropdownProps>={})=>{
88
render(<UserDropdownuser={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
awaitrenderAndClick()
17-
expect(screen.getByText(/account/i)).toBeDefined()
18-
expect(screen.getByText(/documentation/i)).toBeDefined()
19-
expect(screen.getByText(/signout/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
constonSignOut=jest.fn()
2727
awaitrenderAndClick({ onSignOut})
28-
screen.getByText(/signout/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
awaitrenderAndClick()
3636

37-
constlink=screen.getByText(/documentation/i).closest("a")
37+
constlink=screen.getByText(Language.docsLabel).closest("a")
3838
if(!link){
3939
thrownewError("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
awaitrenderAndClick()
4747

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp