Skip to content

Commit 45d5ec3

Browse files
committed
add a more exhaustive type test
1 parent 4799421 commit 45d5ec3

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/__tests__/Button.types.test.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
1-
import React from 'react'
1+
import React, {useRef} from 'react'
22
import {Button} from '../Button'
33

44
export function shouldAcceptOnlyAChildProp() {
55
return <Button>child</Button>
66
}
77

8+
export function ShouldAcceptKnownButtonPropsAndDomProps() {
9+
const buttonEl = useRef<HTMLButtonElement>()
10+
return (
11+
<Button
12+
ref={buttonEl}
13+
leadingIcon={() => <></>}
14+
trailingIcon={() => <></>}
15+
size="medium"
16+
variant="primary"
17+
disabled
18+
aria-label="some label"
19+
onClick={e => {
20+
// current target is assignable to HTMLButtonElement
21+
buttonEl.current = e.currentTarget
22+
}}
23+
sx={{
24+
m: 1
25+
}}
26+
>
27+
Child
28+
</Button>
29+
)
30+
}
31+
832
export function shouldNotAcceptOutlandishProps() {
933
// @ts-expect-error system props should not be accepted
1034
return <Button anOutlandshPropThatShouldNotBeAllowedOnA={'Button'} />

0 commit comments

Comments
 (0)