@@ -51,102 +51,106 @@ const mockWithoutIcon = {
51
51
52
52
const children = 'Click me!' ;
53
53
54
- test ( 'Button component' , async ( ) => {
55
- const { container } = renderProvider ( < Button { ...mockProps } > { children } </ Button > ) ;
54
+ describe ( 'Button component' , ( ) => {
55
+ test ( 'Should render Button component' , async ( ) => {
56
+ const { container } = renderProvider ( < Button { ...mockProps } > { children } </ Button > ) ;
56
57
57
- const button = screen . getByRole ( 'button' , { name : / c l i c k / i } ) ;
58
+ const button = screen . getByRole ( 'button' , { name : / c l i c k / i } ) ;
58
59
59
- expect ( button ) . toBeDefined ( ) ;
60
+ expect ( button ) . toBeDefined ( ) ;
60
61
61
- const results = await axe ( container ) ;
62
- expect ( container ) . toHTMLValidate ( ) ;
63
- expect ( results ) . toHaveNoViolations ( ) ;
64
- } ) ;
62
+ const results = await axe ( container ) ;
63
+ expect ( container ) . toHTMLValidate ( ) ;
64
+ expect ( results ) . toHaveNoViolations ( ) ;
65
+ } ) ;
65
66
66
- test ( 'Button without variant nor state' , async ( ) => {
67
- const { container } = renderProvider ( < Button { ...mockPropsNoVariantNorState } > { children } </ Button > ) ;
67
+ test ( 'Button without variant nor state' , async ( ) => {
68
+ const { container } = renderProvider (
69
+ < Button { ...mockPropsNoVariantNorState } > { children } </ Button >
70
+ ) ;
68
71
69
- const button = screen . getByRole ( 'button' , { name : / c l i c k / i } ) ;
72
+ const button = screen . getByRole ( 'button' , { name : / c l i c k / i } ) ;
70
73
71
- expect ( button ) . toBeDefined ( ) ;
74
+ expect ( button ) . toBeDefined ( ) ;
72
75
73
- const results = await axe ( container ) ;
74
- expect ( container ) . toHTMLValidate ( ) ;
75
- expect ( results ) . toHaveNoViolations ( ) ;
76
- } ) ;
76
+ const results = await axe ( container ) ;
77
+ expect ( container ) . toHTMLValidate ( ) ;
78
+ expect ( results ) . toHaveNoViolations ( ) ;
79
+ } ) ;
77
80
78
- test ( 'Button without type nor size' , async ( ) => {
79
- const { container } = renderProvider ( < Button { ...mockPropsNoTypeNorSize } > { children } </ Button > ) ;
81
+ test ( 'Button without type nor size' , async ( ) => {
82
+ const { container } = renderProvider ( < Button { ...mockPropsNoTypeNorSize } > { children } </ Button > ) ;
80
83
81
- const button = screen . getByRole ( 'button' , { name : / c l i c k / i } ) ;
84
+ const button = screen . getByRole ( 'button' , { name : / c l i c k / i } ) ;
82
85
83
- expect ( button ) . toBeDefined ( ) ;
86
+ expect ( button ) . toBeDefined ( ) ;
84
87
85
- const results = await axe ( container ) ;
86
- expect ( container ) . toHTMLValidate ( ) ;
87
- expect ( results ) . toHaveNoViolations ( ) ;
88
- } ) ;
88
+ const results = await axe ( container ) ;
89
+ expect ( container ) . toHTMLValidate ( ) ;
90
+ expect ( results ) . toHaveNoViolations ( ) ;
91
+ } ) ;
89
92
90
- test ( 'Button with loader' , async ( ) => {
91
- const { container } = renderProvider ( < Button { ...mockPropsLoader } > { children } </ Button > ) ;
93
+ test ( 'Button with loader' , async ( ) => {
94
+ const { container } = renderProvider ( < Button { ...mockPropsLoader } > { children } </ Button > ) ;
92
95
93
- const loader = screen . queryByText ( 'loader' ) ;
96
+ const loader = screen . queryByText ( 'loader' ) ;
94
97
95
- expect ( loader ) . toBeDefined ( ) ;
98
+ expect ( loader ) . toBeDefined ( ) ;
96
99
97
- const results = await axe ( container ) ;
98
- expect ( container ) . toHTMLValidate ( ) ;
99
- expect ( results ) . toHaveNoViolations ( ) ;
100
- } ) ;
100
+ const results = await axe ( container ) ;
101
+ expect ( container ) . toHTMLValidate ( ) ;
102
+ expect ( results ) . toHaveNoViolations ( ) ;
103
+ } ) ;
101
104
102
- test ( 'Button with loader as variant' , async ( ) => {
103
- const { queryByText, getByTestId, container } = renderProvider (
104
- < Button { ...mockPropsLoaderAsVariant } > { children } </ Button >
105
- ) ;
105
+ test ( 'Button with loader as variant' , async ( ) => {
106
+ const { queryByText, getByTestId, container } = renderProvider (
107
+ < Button { ...mockPropsLoaderAsVariant } > { children } </ Button >
108
+ ) ;
106
109
107
- // Should only render loader variant
108
- const loader = queryByText ( mockPropsLoaderAsVariant . loader . variant ) ;
109
- expect ( loader ) . toBeNull ( ) ;
110
+ // Should only render loader variant
111
+ const loader = queryByText ( mockPropsLoaderAsVariant . loader . variant ) ;
112
+ expect ( loader ) . toBeNull ( ) ;
110
113
111
- const loaderVariant = getByTestId ( 'loaderStandaloneTestId' ) ;
112
- expect ( loaderVariant ) . toBeDefined ( ) ;
114
+ const loaderVariant = getByTestId ( 'loaderStandaloneTestId' ) ;
115
+ expect ( loaderVariant ) . toBeDefined ( ) ;
113
116
114
- const results = await axe ( container ) ;
115
- expect ( container ) . toHTMLValidate ( ) ;
116
- expect ( results ) . toHaveNoViolations ( ) ;
117
- } ) ;
117
+ const results = await axe ( container ) ;
118
+ expect ( container ) . toHTMLValidate ( ) ;
119
+ expect ( results ) . toHaveNoViolations ( ) ;
120
+ } ) ;
118
121
119
- test ( 'Button without icon' , async ( ) => {
120
- const { queryByRole, container } = renderProvider (
121
- < Button { ...mockWithoutIcon } > { children } </ Button >
122
- ) ;
122
+ test ( 'Button without icon' , async ( ) => {
123
+ const { queryByRole, container } = renderProvider (
124
+ < Button { ...mockWithoutIcon } > { children } </ Button >
125
+ ) ;
123
126
124
- expect ( queryByRole ( 'img' ) ) . toBeNull ( ) ;
127
+ expect ( queryByRole ( 'img' ) ) . toBeNull ( ) ;
125
128
126
- const results = await axe ( container ) ;
127
- expect ( container ) . toHTMLValidate ( ) ;
128
- expect ( results ) . toHaveNoViolations ( ) ;
129
- } ) ;
129
+ const results = await axe ( container ) ;
130
+ expect ( container ) . toHTMLValidate ( ) ;
131
+ expect ( results ) . toHaveNoViolations ( ) ;
132
+ } ) ;
130
133
131
- test ( 'Button without children and icon' , async ( ) => {
132
- const { container } = renderProvider ( < Button { ...mockWithoutIcon } > </ Button > ) ;
134
+ test ( 'Button without children and icon' , async ( ) => {
135
+ const { container } = renderProvider ( < Button { ...mockWithoutIcon } > </ Button > ) ;
133
136
134
- expect ( container ) . toBeEmptyDOMElement ( ) ;
137
+ expect ( container ) . toBeEmptyDOMElement ( ) ;
135
138
136
- const results = await axe ( container ) ;
137
- expect ( container ) . toHTMLValidate ( ) ;
138
- expect ( results ) . toHaveNoViolations ( ) ;
139
- } ) ;
139
+ const results = await axe ( container ) ;
140
+ expect ( container ) . toHTMLValidate ( ) ;
141
+ expect ( results ) . toHaveNoViolations ( ) ;
142
+ } ) ;
140
143
141
- test ( 'should render an SVG if icon prop is provided' , async ( ) => {
142
- const { container } = renderProvider (
143
- < Button icon = { { icon : 'icon' , altText : 'altIcon' } } size = "LARGE" variant = "PRIMARY" />
144
- ) ;
144
+ test ( 'should render an SVG if icon prop is provided' , async ( ) => {
145
+ const { container } = renderProvider (
146
+ < Button icon = { { icon : 'icon' , altText : 'altIcon' } } size = "LARGE" variant = "PRIMARY" />
147
+ ) ;
145
148
146
- const svg = screen . getByRole ( 'img' , { name : / a l t I c o n / i } ) ;
149
+ const svg = screen . getByRole ( 'img' , { name : / a l t I c o n / i } ) ;
147
150
148
- expect ( svg ) . toBeInTheDocument ( ) ;
149
- const results = await axe ( container ) ;
150
- expect ( container ) . toHTMLValidate ( ) ;
151
- expect ( results ) . toHaveNoViolations ( ) ;
151
+ expect ( svg ) . toBeInTheDocument ( ) ;
152
+ const results = await axe ( container ) ;
153
+ expect ( container ) . toHTMLValidate ( ) ;
154
+ expect ( results ) . toHaveNoViolations ( ) ;
155
+ } ) ;
152
156
} ) ;
0 commit comments