@@ -351,7 +351,33 @@ describe("[Unit] ElementAssertion.test.ts", () => {
351351 const divTest = getByTestId ( "test-div" ) ;
352352 const test = new ElementAssertion ( divTest ) ;
353353
354- expect ( test . toHaveSomeStyle ( { color : "red" , display : "block" } ) ) . toBeEqual ( test ) ;
354+ expect ( test . toHaveSomeStyle ( { color : "blue" , display : "flex" } ) ) . toBeEqual ( test ) ;
355+
356+ expect ( ( ) => test . not . toHaveSomeStyle ( { color : "blue" } ) )
357+ . toThrowError ( AssertionError )
358+ // eslint-disable-next-line max-len
359+ . toHaveMessage ( "Expected the element NOT to match some of the following styles:\n{\n \"color\": \"rgb(0, 0, 255)\"\n}" ) ;
360+ } ) ;
361+ } ) ;
362+
363+ context ( "when the element does not contain any of the expected styles" , ( ) => {
364+ it ( "throws an assertion error" , ( ) => {
365+ const { getByTestId } = render (
366+ < div
367+ className = "foo bar test"
368+ style = { { border : "1px solid black" , color : "blue" , display : "block" } }
369+ data-testid = "test-div"
370+ /> ,
371+ ) ;
372+ const divTest = getByTestId ( "test-div" ) ;
373+ const test = new ElementAssertion ( divTest ) ;
374+
375+ expect ( ( ) => test . toHaveSomeStyle ( { color : "red" , display : "flex" } ) )
376+ . toThrowError ( AssertionError )
377+ // eslint-disable-next-line max-len
378+ . toHaveMessage ( "Expected the element to match some of the following styles:\n{\n \"color\": \"rgb(255, 0, 0)\",\n \"display\": \"flex\"\n}" ) ;
379+
380+ expect ( test . not . toHaveSomeStyle ( { border : "1px solid blue" , color : "red" , display : "flex" } ) ) . toBeEqual ( test ) ;
355381 } ) ;
356382 } ) ;
357383 } ) ;
0 commit comments