Skip to content

Commit 6988a67

Browse files
authoredMar 24, 2022
fix: clarify toHaveFocus message when using .not (#447)
1 parent 4d0ceeb commit 6988a67

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed
 

‎src/to-have-focus.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ export function toHaveFocus(element) {
1313
'',
1414
),
1515
'',
16-
'Expected element with focus:',
17-
` ${this.utils.printExpected(element)}`,
18-
'Received element with focus:',
19-
` ${this.utils.printReceived(element.ownerDocument.activeElement)}`,
16+
...(this.isNot
17+
? [
18+
'Received element is focused:',
19+
` ${this.utils.printReceived(element)}`,
20+
]
21+
: [
22+
'Expected element with focus:',
23+
` ${this.utils.printExpected(element)}`,
24+
'Received element with focus:',
25+
` ${this.utils.printReceived(
26+
element.ownerDocument.activeElement,
27+
)}`,
28+
]),
2029
].join('\n')
2130
},
2231
}

0 commit comments

Comments
 (0)
Please sign in to comment.