@@ -10,6 +10,7 @@ import { NestedElementsTest } from "./fixtures/NestedElementsTest";
1010import { SimpleTest } from "./fixtures/SimpleTest" ;
1111import { WithAttributesTest } from "./fixtures/WithAttributesTest" ;
1212
13+
1314describe ( "[Unit] ElementAssertion.test.ts" , ( ) => {
1415 describe ( ".toBeInTheDocument" , ( ) => {
1516 context ( "when the element is in the document" , ( ) => {
@@ -259,8 +260,8 @@ describe("[Unit] ElementAssertion.test.ts", () => {
259260 const test = new ElementAssertion ( divTest ) ;
260261
261262 expect ( ( ) => test . toHaveAllClasses ( "foo" , "bar" , "baz" ) )
262- . toThrowError ( AssertionError )
263- . toHaveMessage ( 'Expected the element to have all of these classes: "foo bar baz"' ) ;
263+ . toThrowError ( AssertionError )
264+ . toHaveMessage ( 'Expected the element to have all of these classes: "foo bar baz"' ) ;
264265
265266 expect ( test . not . toHaveAllClasses ( "foo" , "bar" , "baz" ) ) . toBeEqual ( test ) ;
266267 } ) ;
@@ -301,11 +302,12 @@ describe("[Unit] ElementAssertion.test.ts", () => {
301302 context ( "when the element has the expected style" , ( ) => {
302303 it ( "returns the assertion instance" , ( ) => {
303304 const { getByTestId } = render (
304- < div
305- className = "foo bar test"
306- style = { { border : "1px solid black" , color : "red" , display : "flex" } }
307- data-testid = "test-div"
308- /> ) ;
305+ < div
306+ className = "foo bar test"
307+ style = { { border : "1px solid black" , color : "red" , display : "flex" } }
308+ data-testid = "test-div"
309+ /> ,
310+ ) ;
309311 const divTest = getByTestId ( "test-div" ) ;
310312 const test = new ElementAssertion ( divTest ) ;
311313
@@ -314,99 +316,102 @@ describe("[Unit] ElementAssertion.test.ts", () => {
314316 expect ( ( ) => test . not . toHaveStyle ( { border : "1px solid black" , color : "red" , display : "flex" } ) )
315317 . toThrowError ( AssertionError )
316318 . toHaveMessage (
317- // eslint-disable-next-line max-len
318- '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}' ,
319+
320+ "Expected the element to NOT match the following style:\n"
321+ + '{\n "border": "1px solid black",\n "color": "rgb(255, 0, 0)",\n "display": "flex"\n}' ,
319322 ) ;
320323 } ) ;
321324 } ) ;
322325
323326 context ( "when the element does not have the expected style" , ( ) => {
324- it ( "throws an assertion error" , ( ) => {
325- const { getByTestId } = render (
326- < div
327- className = "foo bar test"
328- style = { { color : "blue" , display : "block" } }
329- data-testid = "test-div"
330- /> ,
331- ) ;
327+ it ( "throws an assertion error" , ( ) => {
328+ const { getByTestId } = render (
329+ < div
330+ className = "foo bar test"
331+ style = { { color : "blue" , display : "block" } }
332+ data-testid = "test-div"
333+ /> ,
334+ ) ;
335+
336+ const divTest = getByTestId ( "test-div" ) ;
337+ const test = new ElementAssertion ( divTest ) ;
332338
333- const divTest = getByTestId ( "test-div" ) ;
334- const test = new ElementAssertion ( divTest ) ;
339+ expect ( ( ) => test . toHaveStyle ( ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) )
340+ . toThrowError ( AssertionError )
341+ . toHaveMessage (
335342
336- expect ( ( ) => test . toHaveStyle ( ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) )
337- . toThrowError ( AssertionError )
338- . toHaveMessage (
339- // eslint-disable-next-line max-len
340- 'Expected the element to match the following style:\n{\n "border": "1px solid black",\n "color": "rgb(255, 0, 0)",\n "display": "flex"\n}' ,
343+ "Expected the element to match the following style:\n"
344+ + '{\n "border": "1px solid black",\n "color": "rgb(255, 0, 0)",\n "display": "flex"\n}' ,
341345 ) ;
342346
343- expect ( test . not . toHaveStyle ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) . toBeEqual ( test ) ;
344-
345- } ) ;
347+ expect ( test . not . toHaveStyle ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) . toBeEqual ( test ) ;
348+ } ) ;
346349 } ) ;
347350 context ( "when the element partially match the style" , ( ) => {
348- it ( "throws an assertion error" , ( ) => {
349- const { getByTestId } = render (
350- < div
351- className = "foo bar test"
352- style = { { border : "1px solid black" , color : "blue" , display : "block" } }
353- data-testid = "test-div"
354- /> ,
355- ) ;
351+ it ( "throws an assertion error" , ( ) => {
352+ const { getByTestId } = render (
353+ < div
354+ className = "foo bar test"
355+ style = { { border : "1px solid black" , color : "blue" , display : "block" } }
356+ data-testid = "test-div"
357+ /> ,
358+ ) ;
356359
357- const divTest = getByTestId ( "test-div" ) ;
358- const test = new ElementAssertion ( divTest ) ;
360+ const divTest = getByTestId ( "test-div" ) ;
361+ const test = new ElementAssertion ( divTest ) ;
359362
360- expect ( ( ) => test . toHaveStyle ( ( { color : "red" , display : "flex" } ) ) )
361- . toThrowError ( AssertionError )
362- . toHaveMessage (
363- // eslint-disable-next-line max-len
364- 'Expected the element to match the following style:\n{\n "color": "rgb(255, 0, 0)",\n "display": "flex"\n}' ,
365- ) ;
363+ expect ( ( ) => test . toHaveStyle ( ( { color : "red" , display : "flex" } ) ) )
364+ . toThrowError ( AssertionError )
365+ . toHaveMessage (
366366
367- expect ( test . not . toHaveStyle ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) . toBeEqual ( test ) ;
367+ "Expected the element to match the following style:\n"
368+ + '{\n "color": "rgb(255, 0, 0)",\n "display": "flex"\n}' ,
369+ ) ;
368370
369- } ) ;
371+ expect ( test . not . toHaveStyle ( { border : "1px solid black" , color : "red" , display : "flex" } ) ) . toBeEqual ( test ) ;
372+ } ) ;
370373 } ) ;
371374 } ) ;
372375
373376 describe ( ".toHaveSomeStyle" , ( ) => {
374377 context ( "when the element contains one or more expected styles" , ( ) => {
375378 it ( "returns the assertion instance" , ( ) => {
376379 const { getByTestId } = render (
377- < div
378- style = { { color : "blue" , maxHeight : "3rem" , width : "2rem" } }
379- data-testid = "test-div"
380- /> ,
381- ) ;
380+ < div
381+ style = { { color : "blue" , maxHeight : "3rem" , width : "2rem" } }
382+ data-testid = "test-div"
383+ /> ,
384+ ) ;
382385 const divTest = getByTestId ( "test-div" ) ;
383386 const test = new ElementAssertion ( divTest ) ;
384387
385388 expect ( test . toHaveSomeStyle ( { color : "red" , display : "flex" , height : "3rem" , width : "2rem" } ) ) . toBeEqual ( test ) ;
386389
387390 expect ( ( ) => test . not . toHaveSomeStyle ( { color : "blue" } ) )
388- . toThrowError ( AssertionError )
389- // eslint-disable-next-line max-len
390- . toHaveMessage ( "Expected the element NOT to match some of the following styles:\n{\n \"color\": \"rgb(0, 0, 255)\"\n}" ) ;
391+ . toThrowError ( AssertionError )
392+
393+ . toHaveMessage ( "Expected the element NOT to match some of the following styles:\n"
394+ + "{\n \"color\": \"rgb(0, 0, 255)\"\n}" ) ;
391395 } ) ;
392396 } ) ;
393397
394398 context ( "when the element does not contain any of the expected styles" , ( ) => {
395399 it ( "throws an assertion error" , ( ) => {
396400 const { getByTestId } = render (
397- < div
398- className = "foo bar test"
399- style = { { border : "1px solid black" , color : "blue" , display : "block" } }
400- data-testid = "test-div"
401- /> ,
402- ) ;
401+ < div
402+ className = "foo bar test"
403+ style = { { border : "1px solid black" , color : "blue" , display : "block" } }
404+ data-testid = "test-div"
405+ /> ,
406+ ) ;
403407 const divTest = getByTestId ( "test-div" ) ;
404408 const test = new ElementAssertion ( divTest ) ;
405409
406410 expect ( ( ) => test . toHaveSomeStyle ( { color : "red" , display : "flex" } ) )
407- . toThrowError ( AssertionError )
408- // eslint-disable-next-line max-len
409- . toHaveMessage ( "Expected the element to match some of the following styles:\n{\n \"color\": \"rgb(255, 0, 0)\",\n \"display\": \"flex\"\n}" ) ;
411+ . toThrowError ( AssertionError )
412+
413+ . toHaveMessage ( "Expected the element to match some of the following styles:\n"
414+ + "{\n \"color\": \"rgb(255, 0, 0)\",\n \"display\": \"flex\"\n}" ) ;
410415
411416 expect ( test . not . toHaveSomeStyle ( { border : "1px solid blue" , color : "red" , display : "flex" } ) ) . toBeEqual ( test ) ;
412417 } ) ;
0 commit comments