@@ -3,11 +3,11 @@ import { render } from "@testing-library/react";
33
44import { ElementAssertion } from "../../../src/lib/ElementAssertion" ;
55
6- import { FocusTestComponent } from "./fixtures/focusTestComponent" ;
76import { HaveClassTest } from "./fixtures/HaveClassTest" ;
87import { NestedElementsTest } from "./fixtures/NestedElementsTest" ;
98import { SimpleTest } from "./fixtures/SimpleTest" ;
109import { WithAttributesTest } from "./fixtures/WithAttributesTest" ;
10+ import { FocusTestComponent } from "./fixtures/focusTestComponent" ;
1111
1212describe ( "[Unit] ElementAssertion.test.ts" , ( ) => {
1313 describe ( ".toBeInTheDocument" , ( ) => {
@@ -258,8 +258,8 @@ describe("[Unit] ElementAssertion.test.ts", () => {
258258 const test = new ElementAssertion ( divTest ) ;
259259
260260 expect ( ( ) => test . toHaveAllClasses ( "foo" , "bar" , "baz" ) )
261- . toThrowError ( AssertionError )
262- . toHaveMessage ( 'Expected the element to have all of these classes: "foo bar baz"' ) ;
261+ . toThrowError ( AssertionError )
262+ . toHaveMessage ( 'Expected the element to have all of these classes: "foo bar baz"' ) ;
263263
264264 expect ( test . not . toHaveAllClasses ( "foo" , "bar" , "baz" ) ) . toBeEqual ( test ) ;
265265 } ) ;
@@ -300,11 +300,12 @@ describe("[Unit] ElementAssertion.test.ts", () => {
300300 context ( "when the element has the expected style" , ( ) => {
301301 it ( "returns the assertion instance" , ( ) => {
302302 const { getByTestId } = render (
303- < div
304- className = "foo bar test"
305- style = { { border : "1px solid black" , color : "red" , display : "flex" } }
306- data-testid = "test-div"
307- /> ) ;
303+ < div
304+ className = "foo bar test"
305+ style = { { border : "1px solid black" , color : "red" , display : "flex" } }
306+ data-testid = "test-div"
307+ /> ,
308+ ) ;
308309 const divTest = getByTestId ( "test-div" ) ;
309310 const test = new ElementAssertion ( divTest ) ;
310311
@@ -313,99 +314,102 @@ describe("[Unit] ElementAssertion.test.ts", () => {
313314 expect ( ( ) => test . not . toHaveStyle ( { border : "1px solid black" , color : "red" , display : "flex" } ) )
314315 . toThrowError ( AssertionError )
315316 . toHaveMessage (
316- // eslint-disable-next-line max-len
317- 'Expected the element to NOT match the following style:\n{\n "border": "1px solid black",\n "color": "rgb(255, 0, 0)",\n "display": "flex"\n}' ,
317+
318+ "Expected the element to NOT match the following style:\n"
319+ + '{\n "border": "1px solid black",\n "color": "rgb(255, 0, 0)",\n "display": "flex"\n}' ,
318320 ) ;
319321 } ) ;
320322 } ) ;
321323
322324 context ( "when the element does not have the expected style" , ( ) => {
323- it ( "throws an assertion error" , ( ) => {
324- const { getByTestId } = render (
325- < div
326- className = "foo bar test"
327- style = { { color : "blue" , display : "block" } }
328- data-testid = "test-div"
329- /> ,
330- ) ;
325+ it ( "throws an assertion error" , ( ) => {
326+ const { getByTestId } = render (
327+ < div
328+ className = "foo bar test"
329+ style = { { color : "blue" , display : "block" } }
330+ data-testid = "test-div"
331+ /> ,
332+ ) ;
331333
332- const divTest = getByTestId ( "test-div" ) ;
333- const test = new ElementAssertion ( divTest ) ;
334+ const divTest = getByTestId ( "test-div" ) ;
335+ const test = new ElementAssertion ( divTest ) ;
334336
335- expect ( ( ) => test . toHaveStyle ( ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) )
336- . toThrowError ( AssertionError )
337- . toHaveMessage (
338- // eslint-disable-next-line max-len
339- 'Expected the element to match the following style:\n{\n "border": "1px solid black",\n "color": "rgb(255, 0, 0)",\n "display": "flex"\n}' ,
340- ) ;
337+ expect ( ( ) => test . toHaveStyle ( ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) )
338+ . toThrowError ( AssertionError )
339+ . toHaveMessage (
341340
342- expect ( test . not . toHaveStyle ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) . toBeEqual ( test ) ;
341+ "Expected the element to match the following style:\n"
342+ + '{\n "border": "1px solid black",\n "color": "rgb(255, 0, 0)",\n "display": "flex"\n}' ,
343+ ) ;
343344
344- } ) ;
345+ expect ( test . not . toHaveStyle ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) . toBeEqual ( test ) ;
346+ } ) ;
345347 } ) ;
346348 context ( "when the element partially match the style" , ( ) => {
347- it ( "throws an assertion error" , ( ) => {
348- const { getByTestId } = render (
349- < div
350- className = "foo bar test"
351- style = { { border : "1px solid black" , color : "blue" , display : "block" } }
352- data-testid = "test-div"
353- /> ,
354- ) ;
349+ it ( "throws an assertion error" , ( ) => {
350+ const { getByTestId } = render (
351+ < div
352+ className = "foo bar test"
353+ style = { { border : "1px solid black" , color : "blue" , display : "block" } }
354+ data-testid = "test-div"
355+ /> ,
356+ ) ;
355357
356- const divTest = getByTestId ( "test-div" ) ;
357- const test = new ElementAssertion ( divTest ) ;
358+ const divTest = getByTestId ( "test-div" ) ;
359+ const test = new ElementAssertion ( divTest ) ;
358360
359- expect ( ( ) => test . toHaveStyle ( ( { color : "red" , display : "flex" } ) ) )
360- . toThrowError ( AssertionError )
361- . toHaveMessage (
362- // eslint-disable-next-line max-len
363- 'Expected the element to match the following style:\n{\n "color": "rgb(255, 0, 0)",\n "display": "flex"\n}' ,
364- ) ;
361+ expect ( ( ) => test . toHaveStyle ( ( { color : "red" , display : "flex" } ) ) )
362+ . toThrowError ( AssertionError )
363+ . toHaveMessage (
365364
366- expect ( test . not . toHaveStyle ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) . toBeEqual ( test ) ;
365+ "Expected the element to match the following style:\n"
366+ + '{\n "color": "rgb(255, 0, 0)",\n "display": "flex"\n}' ,
367+ ) ;
367368
368- } ) ;
369+ expect ( test . not . toHaveStyle ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) . toBeEqual ( test ) ;
370+ } ) ;
369371 } ) ;
370372 } ) ;
371373
372374 describe ( ".toHaveSomeStyle" , ( ) => {
373375 context ( "when the element contains one or more expected styles" , ( ) => {
374376 it ( "returns the assertion instance" , ( ) => {
375377 const { getByTestId } = render (
376- < div
377- style = { { color : "blue" , maxHeight : "3rem" , width : "2rem" } }
378- data-testid = "test-div"
379- /> ,
380- ) ;
378+ < div
379+ style = { { color : "blue" , maxHeight : "3rem" , width : "2rem" } }
380+ data-testid = "test-div"
381+ /> ,
382+ ) ;
381383 const divTest = getByTestId ( "test-div" ) ;
382384 const test = new ElementAssertion ( divTest ) ;
383385
384386 expect ( test . toHaveSomeStyle ( { color : "red" , display : "flex" , height : "3rem" , width : "2rem" } ) ) . toBeEqual ( test ) ;
385387
386388 expect ( ( ) => test . not . toHaveSomeStyle ( { color : "blue" } ) )
387- . toThrowError ( AssertionError )
388- // eslint-disable-next-line max-len
389- . toHaveMessage ( "Expected the element NOT to match some of the following styles:\n{\n \"color\": \"rgb(0, 0, 255)\"\n}" ) ;
389+ . toThrowError ( AssertionError )
390+
391+ . toHaveMessage ( "Expected the element NOT to match some of the following styles:\n"
392+ + "{\n \"color\": \"rgb(0, 0, 255)\"\n}" ) ;
390393 } ) ;
391394 } ) ;
392395
393396 context ( "when the element does not contain any of the expected styles" , ( ) => {
394397 it ( "throws an assertion error" , ( ) => {
395398 const { getByTestId } = render (
396- < div
397- className = "foo bar test"
398- style = { { border : "1px solid black" , color : "blue" , display : "block" } }
399- data-testid = "test-div"
400- /> ,
401- ) ;
399+ < div
400+ className = "foo bar test"
401+ style = { { border : "1px solid black" , color : "blue" , display : "block" } }
402+ data-testid = "test-div"
403+ /> ,
404+ ) ;
402405 const divTest = getByTestId ( "test-div" ) ;
403406 const test = new ElementAssertion ( divTest ) ;
404407
405408 expect ( ( ) => test . toHaveSomeStyle ( { color : "red" , display : "flex" } ) )
406- . toThrowError ( AssertionError )
407- // eslint-disable-next-line max-len
408- . toHaveMessage ( "Expected the element to match some of the following styles:\n{\n \"color\": \"rgb(255, 0, 0)\",\n \"display\": \"flex\"\n}" ) ;
409+ . toThrowError ( AssertionError )
410+
411+ . toHaveMessage ( "Expected the element to match some of the following styles:\n"
412+ + "{\n \"color\": \"rgb(255, 0, 0)\",\n \"display\": \"flex\"\n}" ) ;
409413
410414 expect ( test . not . toHaveSomeStyle ( { border : "1px solid blue" , color : "red" , display : "flex" } ) ) . toBeEqual ( test ) ;
411415 } ) ;
0 commit comments