-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobUtil.test.ts
33 lines (28 loc) · 1.95 KB
/
globUtil.test.ts
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 { globUtil } from '../src/util/glob-util'
describe('globUtil testing', () => {
test('isMatched', () => {
expect(globUtil.isMatch('eslint-plugin-import', ['react', 'eslint-plugin-*'])).toBeTruthy()
expect(globUtil.isMatch('eslint-plugin-import', ['react', 'eslint-plugin-+(import|game)'])).toBeTruthy()
expect(globUtil.isMatch('eslint-plugin-import', ['react', 'eslint-plugin-!(import|game)'])).toBeFalsy()
expect(globUtil.isMatch('@babel/core', ['@babel/*'])).toBeTruthy()
expect(globUtil.isMatch('@babel/core', ['!@babel/*'])).toBeFalsy()
expect(globUtil.isMatch('react', ['react', '!react'])).toBeTruthy()
expect(globUtil.isMatch('react', ['!(react)', 'react'])).toBeTruthy()
expect(globUtil.isMatch('react', ['re*/'])).toBeFalsy()
expect(globUtil.isMatch('@babel/core', ['@@@@@/*'])).toBeFalsy()
expect(globUtil.isMatch('@babel/core', ['@+&^1.)13##$$/*'])).toBeFalsy()
})
test('toRegex', () => {
expect(globUtil.toRegex(['react', 'eslint-plugin-*']).test('react')).toBeTruthy()
expect(globUtil.toRegex(['react', 'eslint-plugin-*']).test('eslint-plugin-imports')).toBeTruthy()
expect(globUtil.toRegex(['react', 'eslint-plugin-*']).test('abc')).toBeFalsy()
expect(globUtil.toRegex(['react', 'eslint-plugin-+(import|game)']).test('eslint-plugin-import')).toBeTruthy()
expect(globUtil.toRegex(['react', 'eslint-plugin-!(import|game)']).test('eslint-plugin-import')).toBeFalsy()
expect(globUtil.toRegex(['@babel/*']).test('@babel/core')).toBeTruthy()
expect(globUtil.toRegex(['!@babel/*']).test('@babel/core')).toBeFalsy()
expect(globUtil.toRegex(['@(nx)']).test('@nx/nx')).toBeFalsy()
expect(globUtil.toRegex(['react', '!react']).test('react')).toBeTruthy()
expect(globUtil.toRegex(['!(react)', 'react']).test('react')).toBeTruthy()
expect(globUtil.toRegex(['re*/']).test('re')).toBeFalsy()
})
})