-
-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathmatcher.test.ts
More file actions
33 lines (28 loc) · 1.17 KB
/
matcher.test.ts
File metadata and controls
33 lines (28 loc) · 1.17 KB
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
29
30
31
32
33
import { describe, expect, it } from 'vitest'
import { matcher } from './matcher'
describe('matcher', () => {
it('returns false when patterns is empty', () => {
expect(matcher([], 'foo')).toBe(false)
})
it('matches string patterns against component names', () => {
const patterns = ['Button', 'MyComponent']
expect(matcher(patterns, 'Button')).toBe(true)
expect(matcher(patterns, 'Other')).toBe(false)
})
it('matches regex patterns against component names', () => {
const patterns = [/^Button$/, /Comp/]
expect(matcher(patterns, 'Button')).toBe(true)
expect(matcher(patterns, 'MyComp')).toBe(true)
expect(matcher(patterns, 'NoMatch')).toBe(false)
})
it('matches file paths with glob patterns', () => {
const patterns = ['**/ignored-file.jsx']
expect(matcher(patterns, 'src/components/ignored-file.jsx')).toBe(true)
expect(matcher(patterns, 'src/components/other.jsx')).toBe(false)
})
it('matches file paths with regex', () => {
const patterns = [/ignored-file\.jsx$/]
expect(matcher(patterns, 'src/components/ignored-file.jsx')).toBe(true)
expect(matcher(patterns, 'src/components/other.jsx')).toBe(false)
})
})