forked from testing-library/dom-testing-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatches.js
28 lines (22 loc) · 892 Bytes
/
matches.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import {fuzzyMatches, matches} from '../matches'
// unit tests for text match utils
const node = null
const normalizer = str => str
test('matchers accept strings', () => {
expect(matches('ABC', node, 'ABC', normalizer)).toBe(true)
expect(fuzzyMatches('ABC', node, 'ABC', normalizer)).toBe(true)
})
test('matchers accept regex', () => {
expect(matches('ABC', node, /ABC/, normalizer)).toBe(true)
expect(fuzzyMatches('ABC', node, /ABC/, normalizer)).toBe(true)
})
test('matchers accept functions', () => {
expect(matches('ABC', node, text => text === 'ABC', normalizer)).toBe(true)
expect(fuzzyMatches('ABC', node, text => text === 'ABC', normalizer)).toBe(
true,
)
})
test('matchers return false if text to match is not a string', () => {
expect(matches(null, node, 'ABC', normalizer)).toBe(false)
expect(fuzzyMatches(null, node, 'ABC', normalizer)).toBe(false)
})