diff --git a/src/components/disclosure/disclosure.test.tsx b/src/components/disclosure/disclosure.test.tsx index a6528a2..6c72cff 100644 --- a/src/components/disclosure/disclosure.test.tsx +++ b/src/components/disclosure/disclosure.test.tsx @@ -20,7 +20,7 @@ jest.mock('../../hooks/use-id') afterAll(() => jest.restoreAllMocks()) function nextFrame() { - return new Promise(resolve => { + return new Promise(resolve => { requestAnimationFrame(() => { requestAnimationFrame(() => { resolve() @@ -296,6 +296,66 @@ describe('Rendering', () => { assertDisclosurePanel({ state: DisclosureState.Visible }) }) ) + + describe('`type` attribute', () => { + it('should set the `type` to "button" by default', async () => { + render( + + Trigger + + ) + + expect(getDisclosureButton()).toHaveAttribute('type', 'button') + }) + + it('should not set the `type` to "button" if it already contains a `type`', async () => { + render( + + Trigger + + ) + + expect(getDisclosureButton()).toHaveAttribute('type', 'submit') + }) + + it('should set the `type` to "button" when using the `as` prop which resolves to a "button"', async () => { + let CustomButton = React.forwardRef((props, ref) => ( +