Skip to content

Commit

Permalink
fix: fixed bug in toHaveAttribute check on style (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmonro committed Sep 10, 2020
1 parent d639db4 commit 167137a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/__tests__/lib/rules/prefer-to-have-style.js
Expand Up @@ -11,6 +11,11 @@ ruleTester.run("prefer-to-have-style", rule, {
`expect(el.style).toMatchSnapshot()`,
`expect(el.style).toEqual(foo)`,
`expect(el).toHaveAttribute("style")`,
`React.useLayoutEffect(() => {
if (foo) {
document.body.setAttribute("style", "foo");
}
}, [foo]);`,
],
invalid: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-to-have-style.js
Expand Up @@ -109,7 +109,7 @@ export const create = (context) => ({
},

//expect(el).toHaveAttribute("style", "foo: bar");
[`CallExpression[callee.property.name][arguments.0.value=style][arguments.1]`](
[`CallExpression[callee.property.name=toHaveAttribute][arguments.0.value=style][arguments.1][callee.object.callee.name=expect]`](
node
) {
context.report({
Expand Down

0 comments on commit 167137a

Please sign in to comment.