test: improve test coverage (#7181)

This commit is contained in:
Joshua Chen 2022-04-16 16:35:40 +08:00 committed by GitHub
parent 44966e19e9
commit f219a2ac90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 14 deletions

View file

@ -12,9 +12,8 @@ import {
} from '../globUtils';
describe('createMatcher', () => {
const matcher = createMatcher(GlobExcludeDefault);
it('match default exclude MD/MDX partials correctly', () => {
const matcher = createMatcher(GlobExcludeDefault);
expect(matcher('doc.md')).toBe(false);
expect(matcher('category/doc.md')).toBe(false);
expect(matcher('category/subcategory/doc.md')).toBe(false);
@ -32,6 +31,7 @@ describe('createMatcher', () => {
});
it('match default exclude tests correctly', () => {
const matcher = createMatcher(GlobExcludeDefault);
expect(matcher('xyz.js')).toBe(false);
expect(matcher('xyz.ts')).toBe(false);
expect(matcher('xyz.jsx')).toBe(false);
@ -63,6 +63,13 @@ describe('createMatcher', () => {
expect(matcher('folder/__tests__/xyz.jsx')).toBe(true);
expect(matcher('folder/__tests__/xyz.tsx')).toBe(true);
});
it('matches nothing given nothing', () => {
const matcher = createMatcher([]);
expect(matcher('foo')).toBe(false);
expect(matcher('')).toBe(false);
expect(matcher('we/are/the/champions')).toBe(false);
});
});
describe('createAbsoluteFilePathMatcher', () => {