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

Commit34c2ebb

Browse files
committed
test: improve Storybook tests
1 parent56d1fb7 commit34c2ebb

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

‎site/src/components/UserDropdown/UserDropdown.stories.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ ExampleNoRoles.args = {
2424
returnPromise.resolve()
2525
},
2626
}
27+
28+
exportconstOpen=Template.bind({})
29+
Open.args={
30+
isOpen:true,
31+
user:MockUser,
32+
onSignOut:()=>{
33+
returnPromise.resolve()
34+
},
35+
}

‎site/src/components/UserDropdown/UsersDropdown.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ export const Language = {
2222
signOutLabel:"Sign Out",
2323
}
2424
exportinterfaceUserDropdownProps{
25+
isOpen?:boolean// *DO NOT USE* Only used for testing via Storybook
2526
user:TypesGen.User
2627
onSignOut:()=>void
2728
}
2829

29-
exportconstUserDropdown:React.FC<UserDropdownProps>=({ user, onSignOut}:UserDropdownProps)=>{
30+
exportconstUserDropdown:React.FC<UserDropdownProps>=({isOpen,user, onSignOut}:UserDropdownProps)=>{
3031
conststyles=useStyles()
3132
const[anchorEl,setAnchorEl]=useState<HTMLElement|undefined>()
3233

@@ -51,7 +52,7 @@ export const UserDropdown: React.FC<UserDropdownProps> = ({ user, onSignOut }: U
5152
<BorderedMenu
5253
anchorEl={anchorEl}
5354
getContentAnchorEl={null}
54-
open={!!anchorEl}
55+
open={!!anchorEl||!!isOpen}
5556
anchorOrigin={{
5657
vertical:"bottom",
5758
horizontal:"right",

‎site/src/components/UserProfileCard/UserProfileCard.stories.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { MockUser } from "../../testHelpers/entities"
44
import{UserProfileCard,UserProfileCardProps}from"./UserProfileCard"
55

66
exportdefault{
7-
title:"components/UserDropdown",
7+
title:"components/UserProfileCard",
88
component:UserProfileCard,
9-
argTypes:{
10-
onSignOut:{action:"Sign Out"},
11-
},
9+
argTypes:{},
1210
}
1311

1412
constTemplate:Story<UserProfileCardProps>=(args:UserProfileCardProps)=><UserProfileCard{...args}/>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp