@@ -46,7 +46,6 @@ clear to read and to maintain.
46
46
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
47
47
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
48
48
49
-
50
49
- [ Installation] ( #installation )
51
50
- [ Usage] ( #usage )
52
51
- [ Custom matchers] ( #custom-matchers )
@@ -642,7 +641,7 @@ expect(getByTestId('login-form')).toHaveFormValues({
642
641
### ` toHaveStyle `
643
642
644
643
``` typescript
645
- toHaveStyle (css : string )
644
+ toHaveStyle (css : string | object )
646
645
```
647
646
648
647
This allows you to check if a certain element has some specific css properties
@@ -652,7 +651,10 @@ expected properties applied, not just some of them.
652
651
#### Examples
653
652
654
653
``` html
655
- <button data-testid =" delete-button" style =" display : none ; color : red " >
654
+ <button
655
+ data-testid =" delete-button"
656
+ style =" display : none ; background-color : red "
657
+ >
656
658
Delete item
657
659
</button >
658
660
```
@@ -661,14 +663,23 @@ expected properties applied, not just some of them.
661
663
const button = getByTestId (' delete-button' )
662
664
663
665
expect (button).toHaveStyle (' display: none' )
666
+ expect (button).toHaveStyle ({display: ' none' })
664
667
expect (button).toHaveStyle (`
665
- color: red;
668
+ background- color: red;
666
669
display: none;
667
670
` )
671
+ expect (button).toHaveStyle ({
672
+ backgroundColor: ' red' ,
673
+ display: ' none' ,
674
+ })
668
675
expect (button).not .toHaveStyle (`
669
- color: blue;
676
+ background- color: blue;
670
677
display: none;
671
678
` )
679
+ expect (button).not .toHaveStyle ({
680
+ backgroundColor: ' blue' ,
681
+ display: ' none' ,
682
+ })
672
683
```
673
684
674
685
This also works with rules that are applied to the element via a class name for
@@ -928,6 +939,7 @@ Thanks goes to these people ([emoji key][emojis]):
928
939
929
940
<!-- markdownlint-enable -->
930
941
<!-- prettier-ignore-end -->
942
+
931
943
<!-- ALL-CONTRIBUTORS-LIST:END -->
932
944
933
945
This project follows the [ all-contributors] [ all-contributors ] specification.
0 commit comments