Skip to content

Commit

Permalink
*refactor migrate test from enzyme to testng-library
Browse files Browse the repository at this point in the history
  • Loading branch information
Sodik committed Feb 12, 2025
1 parent 01aaa98 commit 51c3dca
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 5 additions & 7 deletions packages/ui/__stories__/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const WithDangerAction = () => (
{
children,
onClick,
kind: 'danger',
color: 'secondary',
},
]}
>
Expand All @@ -124,7 +124,7 @@ export const WithDangerActionDisabled = () => (
onClick,
disabled: true,
disabledTooltip,
kind: 'danger',
color: 'secondary',
},
]}
>
Expand All @@ -145,7 +145,7 @@ export const WithMultipleActions = () => (
{
children,
onClick,
kind: 'danger',
color: 'secondary',
},
]}
>
Expand All @@ -172,10 +172,8 @@ export const WithHiddenModalActions = () => {
id pellentesque eros pretium.
</p>
<div className={styles.footer}>
<Button kind="primary" onClick={onClick}>
Action
</Button>
<Button kind="secondary" onClick={onClose}>
<Button onClick={onClick}>Action</Button>
<Button variant="outlined" onClick={onClose}>
Cancel
</Button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/__stories__/Overlay.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { OverlayProps } from '../src/Overlay'
const content = (
<TabContextProvider>
<TabList ariaLabel="Settings Tabs" className={styles.tablist}>
<Tab label="My Account" value={0} />
<Tab label="Billing" value={1} />
<Tab value={0}>My Account</Tab>
<Tab value={1}>Billing</Tab>
</TabList>
<TabPanel value={0}>
<Card title="Account Information">
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/__stories__/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,15 @@ export const WithIcons = () => (
<TabList ariaLabel="Tabs Story">
<Tab ariaLabel="Tab 1" value={0}>
<Icon icon={Info} ariaLabel="Info" />
Tab 1
</Tab>
<Tab ariaLabel="Tab 2" value={1}>
<Icon icon={PenTool} ariaLabel="PenTool" />
Tab 2
</Tab>
<Tab ariaLabel="Tab 3" value={2}>
<Icon icon={Settings} ariaLabel="Settings" />
Tab 3
</Tab>
</TabList>
<TabPanel value={0}>
Expand Down
30 changes: 16 additions & 14 deletions packages/ui/src/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,30 @@ export const Dialog: FC<DialogProps> = ({
actionOnConfirm,
...rest
}) => {
const actions: ModalProps['actions'] = useMemo(
() =>
const actions = useMemo(() => {
const props: ModalProps['actions'] =
actionChildren && actionOnConfirm
? [
{
autoFocus: !actionDangerous,
kind: actionDangerous ? 'danger' : 'primary',
...(actionDisabled &&
actionDisabledTooltip ? {
disabled: actionDisabled,
disabledTooltip: actionDisabledTooltip,
}:{
disabled: undefined,
disabledTooltip: undefined
}),
color: actionDangerous ? 'secondary' : 'primary',
...(actionDisabled && actionDisabledTooltip
? {
disabled: actionDisabled,
disabledTooltip: actionDisabledTooltip,
}
: {
disabled: undefined,
disabledTooltip: undefined,
}),
onClick: actionOnConfirm,
children: actionChildren,
},
]
: [],
[actionDangerous, actionDisabled, actionDisabledTooltip, actionOnConfirm, actionChildren],
)
: []

return props
}, [actionDangerous, actionDisabled, actionDisabledTooltip, actionOnConfirm, actionChildren])

return (
<Modal
Expand Down
4 changes: 0 additions & 4 deletions packages/ui/src/Tabs/Tab.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
@include c.typographyH3;
@include h.overflowEllipsis;

.icon {
margin-right: c.$grid * 2;
}

&.selected {
color: c.$colorPrimary;
border-radius: 0;
Expand Down

0 comments on commit 51c3dca

Please sign in to comment.