@@ -5,7 +5,6 @@ import { describe, expect, it, jest } from "@jest/globals";
5
5
import { createComponent } from "@lit/react" ;
6
6
import React , { type FormEventHandler } from "react" ;
7
7
import {
8
- getComponent ,
9
8
itShouldMount ,
10
9
itSupportsClassName ,
11
10
itSupportsDataSetProps ,
@@ -19,6 +18,7 @@ const Button = createComponent({
19
18
} ) ;
20
19
21
20
const handleClick = jest . fn ( ) ;
21
+ const getTestButton = ( ) => screen . getByTestId ( "test-button" ) ;
22
22
23
23
const mockRequiredProps = {
24
24
label : "test-button-label" ,
@@ -31,9 +31,8 @@ describe("🧪 button/standard: UI", () => {
31
31
itSupportsDataSetProps ( Button , mockRequiredProps ) ;
32
32
33
33
it ( "should trigger `handleClick` function after clicking on the button" , async ( ) => {
34
- const testButton = getComponent ( Button , {
35
- onClick : handleClick ,
36
- } ) ;
34
+ render ( < Button onClick = { handleClick } /> ) ;
35
+ const testButton = getTestButton ( ) ;
37
36
38
37
const { click } = userEvent . setup ( ) ;
39
38
@@ -43,9 +42,8 @@ describe("🧪 button/standard: UI", () => {
43
42
} ) ;
44
43
45
44
it ( "should trigger `handleClick` function after focusing on the button and pressing Enter" , async ( ) => {
46
- const testButton = getComponent ( Button , {
47
- onClick : handleClick ,
48
- } ) ;
45
+ render ( < Button onClick = { handleClick } /> ) ;
46
+ const testButton = getTestButton ( ) ;
49
47
50
48
const { tab, keyboard } = userEvent . setup ( ) ;
51
49
@@ -57,10 +55,13 @@ describe("🧪 button/standard: UI", () => {
57
55
} ) ;
58
56
59
57
it ( "should not be able to trigger `handleClick` function while `disabled`" , async ( ) => {
60
- const testButton = getComponent ( Button , {
61
- onClick : handleClick ,
62
- disabled : true ,
63
- } ) ;
58
+ render (
59
+ < Button
60
+ onClick = { handleClick }
61
+ disabled
62
+ /> ,
63
+ ) ;
64
+ const testButton = getTestButton ( ) ;
64
65
65
66
const { tab, click } = userEvent . setup ( ) ;
66
67
@@ -72,13 +73,8 @@ describe("🧪 button/standard: UI", () => {
72
73
expect ( handleClick ) . toHaveBeenCalledTimes ( 0 ) ;
73
74
} ) ;
74
75
75
- it ( "should have `aria-label` property when the host has a `label` property" , async ( ) => {
76
- render (
77
- < Button
78
- { ...mockRequiredProps }
79
- label = "test-label"
80
- /> ,
81
- ) ;
76
+ it ( "should have `aria-label` when the host has a `label` property" , async ( ) => {
77
+ render ( < Button label = "test-label" /> ) ;
82
78
83
79
expect (
84
80
await screen . findByShadowTestId ( "tapsi-button-root" ) ,
0 commit comments