Skip to content

Commit fef5a24

Browse files
authored
fix: fixed bug w/ toHaveAttribute("aria-check", "true") (#50)
1 parent 64c9226 commit fef5a24

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
"eslint": "^7.0.0"
4242
},
4343
"eslintConfig": {
44-
"extends": "./node_modules/kcd-scripts/eslint.js"
44+
"extends": "./node_modules/kcd-scripts/eslint.js",
45+
"rules": {
46+
"babel/quotes": "off"
47+
}
4548
},
4649
"eslintIgnore": [
4750
"node_modules",

src/__tests__/__fixtures__/createBannedAttributeTestCases.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,24 @@ export default ({ preferred, negatedPreferred, attribute }) => {
137137
],
138138
output: `expect(element).${preferred}`,
139139
},
140+
{
141+
code: `expect(getByText("foo")).toHaveAttribute("${attribute}", "true")`,
142+
errors: [
143+
{
144+
message: `Use ${preferred} instead of toHaveAttribute("${attribute}", "true")`,
145+
},
146+
],
147+
output: `expect(getByText("foo")).${preferred}`,
148+
},
149+
{
150+
code: `expect(getByText("foo")).toHaveAttribute("${attribute}", "false")`,
151+
errors: [
152+
{
153+
message: `Use ${negatedPreferred} instead of toHaveAttribute("${attribute}", "false")`,
154+
},
155+
],
156+
output: `expect(getByText("foo")).${negatedPreferred}`,
157+
},
140158
{
141159
code: `expect(getByText("foo")).toHaveAttribute("${attribute}", "")`,
142160
errors: [

src/createBannedAttributeRule.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ export default ({ preferred, negatedPreferred, attributes }) => (context) => {
22
const getCorrectFunctionFor = (node, negated = false) =>
33
(node.arguments.length === 1 ||
44
node.arguments[1].value === true ||
5+
(typeof node.arguments[1].value === "string" &&
6+
node.arguments[1].value.toLowerCase() === "true") ||
57
node.arguments[1].value === "") &&
68
!negated
79
? preferred

0 commit comments

Comments
 (0)