Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# React Testing Library Changelog

## 3.1.1
* [#89](https://github.com/Workiva/react_testing_library/pull/89) Escape special characters in ids in `hasDescription` matcher

## 3.1.0
* [#86](https://github.com/Workiva/react_testing_library/pull/86) Add Dart bindings for React `act`

Expand Down
2 changes: 1 addition & 1 deletion lib/src/matchers/jest_dom/has_description.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class _HasDescription extends CustomMatcher with ElementTextContentMatcherMixin

final elementsWithDescriptions = <Element>[];
_idsOfElementsThatDescribe(item)?.forEach((id) {
final elWithDesc = querySelector('#$id');
final elWithDesc = querySelector('#${Css.escape(id)}');
if (elWithDesc != null) {
elementsWithDescriptions.add(elWithDesc);
}
Expand Down
7 changes: 4 additions & 3 deletions test/unit/dom/matchers/has_description_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ void main() {
{},
react.button({
'aria-label': 'Close',
'aria-describedby': 'description-close',
// Use a special character to verify that it is escaped correctly in hasDescription.
'aria-describedby': 'r:description-close',
}, 'X'),
react.button({
'aria-label': 'Has Multiple Descriptions',
'aria-describedby': 'description-close some-other-description',
'aria-describedby': 'r:description-close some-other-description',
}, 'X'),
react.button({}, 'Delete'),
react.button({'aria-describedby': 'not-found'}, 'Has id not found'),
react.div({'id': 'description-close'}, 'Closing will discard any changes'),
react.div({'id': 'r:description-close'}, 'Closing will discard any changes'),
react.div({'id': 'some-other-description'}, 'Some other description'),
));
});
Expand Down