@@ -176,10 +176,9 @@ describe("[Unit] ElementAssertion.test.ts", () => {
176
176
177
177
describe ( ".toHaveClass" , ( ) => {
178
178
context ( "when the element has the expected class" , ( ) => {
179
- it ( "returns the assertion instance" , async ( ) => {
180
- const { findByTestId } = render ( < HaveClassTestComponent /> ) ;
181
- const divTest = await findByTestId ( "classTest" ) ;
182
- divTest . classList . add ( "foo" , "bar" ) ;
179
+ it ( "returns the assertion instance" , ( ) => {
180
+ const { getByText } = render ( < HaveClassTestComponent className = "foo bar" /> ) ;
181
+ const divTest = getByText ( "Test text inside a div" ) ;
183
182
const test = new ElementAssertion ( divTest ) ;
184
183
185
184
expect ( test . toHaveClass ( "foo" ) ) . toBeEqual ( test ) ;
@@ -191,10 +190,9 @@ describe("[Unit] ElementAssertion.test.ts", () => {
191
190
} ) ;
192
191
193
192
context ( "when the element does not have the expected class" , ( ) => {
194
- it ( "throws an assertion error" , async ( ) => {
195
- const { findByTestId } = render ( < HaveClassTestComponent /> ) ;
196
- const divTest = await findByTestId ( "classTest" ) ;
197
- divTest . classList . add ( "foo" , "bar" ) ;
193
+ it ( "throws an assertion error" , ( ) => {
194
+ const { getByText } = render ( < HaveClassTestComponent className = "foo bar" /> ) ;
195
+ const divTest = getByText ( "Test text inside a div" ) ;
198
196
const test = new ElementAssertion ( divTest ) ;
199
197
200
198
expect ( ( ) => test . toHaveClass ( "baz" ) )
@@ -208,10 +206,9 @@ describe("[Unit] ElementAssertion.test.ts", () => {
208
206
209
207
describe ( ".toHaveAnyClass" , ( ) => {
210
208
context ( "when the element has at least one of the expected classes" , ( ) => {
211
- it ( "returns the assertion instance" , async ( ) => {
212
- const { findByTestId } = render ( < HaveClassTestComponent /> ) ;
213
- const divTest = await findByTestId ( "classTest" ) ;
214
- divTest . classList . add ( "foo" , "bar" ) ;
209
+ it ( "returns the assertion instance" , ( ) => {
210
+ const { getByText } = render ( < HaveClassTestComponent className = "foo bar" /> ) ;
211
+ const divTest = getByText ( "Test text inside a div" ) ;
215
212
const test = new ElementAssertion ( divTest ) ;
216
213
217
214
expect ( test . toHaveAnyClass ( "bar" , "baz" ) ) . toBeEqual ( test ) ;
@@ -223,10 +220,9 @@ describe("[Unit] ElementAssertion.test.ts", () => {
223
220
} ) ;
224
221
225
222
context ( "when the element does not have any of the expected classes" , ( ) => {
226
- it ( "throws an assertion error" , async ( ) => {
227
- const { findByTestId } = render ( < HaveClassTestComponent /> ) ;
228
- const divTest = await findByTestId ( "classTest" ) ;
229
- divTest . className = "foo" ;
223
+ it ( "throws an assertion error" , ( ) => {
224
+ const { getByText } = render ( < HaveClassTestComponent className = "foo" /> ) ;
225
+ const divTest = getByText ( "Test text inside a div" ) ;
230
226
const test = new ElementAssertion ( divTest ) ;
231
227
232
228
expect ( ( ) => test . toHaveAnyClass ( "bar" , "baz" ) )
@@ -240,10 +236,9 @@ describe("[Unit] ElementAssertion.test.ts", () => {
240
236
241
237
describe ( ".toHaveAllClasses" , ( ) => {
242
238
context ( "when the element has all the expected classes" , ( ) => {
243
- it ( "returns the assertion instance" , async ( ) => {
244
- const { findByTestId } = render ( < HaveClassTestComponent /> ) ;
245
- const divTest = await findByTestId ( "classTest" ) ;
246
- divTest . classList . add ( "foo" , "bar" , "baz" ) ;
239
+ it ( "returns the assertion instance" , ( ) => {
240
+ const { getByText } = render ( < HaveClassTestComponent className = "foo bar baz" /> ) ;
241
+ const divTest = getByText ( "Test text inside a div" ) ;
247
242
const test = new ElementAssertion ( divTest ) ;
248
243
249
244
expect ( test . toHaveAllClasses ( "foo" , "bar" ) ) . toBeEqual ( test ) ;
@@ -255,9 +250,9 @@ describe("[Unit] ElementAssertion.test.ts", () => {
255
250
} ) ;
256
251
257
252
context ( "when the element does not have all the expected classes" , ( ) => {
258
- it ( "throws an assertion error" , async ( ) => {
259
- const { findByTestId } = render ( < HaveClassTestComponent /> ) ;
260
- const divTest = await findByTestId ( "classTest ") ;
253
+ it ( "throws an assertion error" , ( ) => {
254
+ const { getByText } = render ( < HaveClassTestComponent className = "foo bar" /> ) ;
255
+ const divTest = getByText ( "Test text inside a div ") ;
261
256
divTest . classList . add ( "foo" , "bar" ) ;
262
257
const test = new ElementAssertion ( divTest ) ;
263
258
0 commit comments