Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use exact match for data-testid (#29)
* fix: use exact match for data-testid [fixes #8] * add tests for exact matches * disallow substring match * fix: heading level for getByTestId * Add docs for ExactTextMatch * Update README.md
- Loading branch information
1 parent
6e0c752
commit 7bab309
Showing
5 changed files
with
88 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {matches, matchesExact} from '../' | ||
|
||
// unit tests for text match utils | ||
|
||
const node = null | ||
|
||
test('matches should get fuzzy matches', () => { | ||
// should not match | ||
expect(matchesExact(null, node, 'abc')).toBe(false) | ||
expect(matchesExact('', node, 'abc')).toBe(false) | ||
// should match | ||
expect(matches('ABC', node, 'abc')).toBe(true) | ||
expect(matches('ABC', node, 'ABC')).toBe(true) | ||
}) | ||
|
||
test('matchesExact should only get exact matches', () => { | ||
// should not match | ||
expect(matchesExact(null, node, null)).toBe(false) | ||
expect(matchesExact(null, node, 'abc')).toBe(false) | ||
expect(matchesExact('', node, 'abc')).toBe(false) | ||
expect(matchesExact('ABC', node, 'abc')).toBe(false) | ||
expect(matchesExact('ABC', node, 'A')).toBe(false) | ||
expect(matchesExact('ABC', node, 'ABCD')).toBe(false) | ||
// should match | ||
expect(matchesExact('ABC', node, 'ABC')).toBe(true) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters