Skip to content

Commit 1c21854

Browse files
committed
updates ConfirmationDialog tests for the newer Button
1 parent d35708f commit 1c21854

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/drafts/Dialog2/ConfirmationDialog.test.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,33 +98,33 @@ describe('ConfirmationDialog', () => {
9898
})
9999

100100
it('focuses the primary action when opened and the confirmButtonType is not set', async () => {
101-
const {getByText} = HTMLRender(<Basic />)
101+
const {getByText, getByRole} = HTMLRender(<Basic />)
102102
fireEvent.click(getByText('Show dialog'))
103-
expect(getByText('Primary')).toEqual(document.activeElement)
104-
expect(getByText('Secondary')).not.toEqual(document.activeElement)
103+
expect(getByRole('button', {name: 'Primary'})).toHaveFocus()
104+
expect(getByRole('button', {name: 'Secondary'})).not.toHaveFocus()
105105
})
106106

107107
it('focuses the primary action when opened and the confirmButtonType is not danger', async () => {
108-
const {getByText} = HTMLRender(<Basic confirmButtonType="primary" />)
108+
const {getByText, getByRole} = HTMLRender(<Basic confirmButtonType="primary" />)
109109
fireEvent.click(getByText('Show dialog'))
110-
expect(getByText('Primary')).toEqual(document.activeElement)
111-
expect(getByText('Secondary')).not.toEqual(document.activeElement)
110+
expect(getByRole('button', {name: 'Primary'})).toHaveFocus()
111+
expect(getByRole('button', {name: 'Secondary'})).not.toHaveFocus()
112112
})
113113

114114
it('focuses the secondary action when opened and the confirmButtonType is danger', async () => {
115-
const {getByText} = HTMLRender(<Basic confirmButtonType="danger" />)
115+
const {getByText, getByRole} = HTMLRender(<Basic confirmButtonType="danger" />)
116116
fireEvent.click(getByText('Show dialog'))
117-
expect(getByText('Primary')).not.toEqual(document.activeElement)
118-
expect(getByText('Secondary')).toEqual(document.activeElement)
117+
expect(getByRole('button', {name: 'Primary'})).not.toHaveFocus()
118+
expect(getByRole('button', {name: 'Secondary'})).toHaveFocus()
119119
})
120120

121121
it('supports nested `focusTrap`s', async () => {
122-
const {getByText} = HTMLRender(<ShorthandHookFromActionMenu />)
122+
const {getByText, getByRole} = HTMLRender(<ShorthandHookFromActionMenu />)
123123

124124
fireEvent.click(getByText('Show menu'))
125125
fireEvent.click(getByText('Show dialog'))
126126

127-
expect(getByText('Primary')).toEqual(document.activeElement)
128-
expect(getByText('Secondary')).not.toEqual(document.activeElement)
127+
expect(getByRole('button', {name: 'Primary'})).toHaveFocus()
128+
expect(getByRole('button', {name: 'Secondary'})).not.toHaveFocus()
129129
})
130130
})

0 commit comments

Comments
 (0)