Skip to content

Commit 167137a

Browse files
authored
fix: fixed bug in toHaveAttribute check on style (#81)
1 parent d639db4 commit 167137a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/__tests__/lib/rules/prefer-to-have-style.js

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ ruleTester.run("prefer-to-have-style", rule, {
1111
`expect(el.style).toMatchSnapshot()`,
1212
`expect(el.style).toEqual(foo)`,
1313
`expect(el).toHaveAttribute("style")`,
14+
`React.useLayoutEffect(() => {
15+
if (foo) {
16+
document.body.setAttribute("style", "foo");
17+
}
18+
}, [foo]);`,
1419
],
1520
invalid: [
1621
{

src/rules/prefer-to-have-style.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const create = (context) => ({
109109
},
110110

111111
//expect(el).toHaveAttribute("style", "foo: bar");
112-
[`CallExpression[callee.property.name][arguments.0.value=style][arguments.1]`](
112+
[`CallExpression[callee.property.name=toHaveAttribute][arguments.0.value=style][arguments.1][callee.object.callee.name=expect]`](
113113
node
114114
) {
115115
context.report({

0 commit comments

Comments
 (0)