|
| 1 | +import { hasSrcDirectoryInclude } from '../typescript-config'; |
| 2 | + |
| 3 | +describe('typescript-config', () => { |
| 4 | + describe('hasSrcDirectoryInclude', () => { |
| 5 | + it('returns `false` for a non-array argument', () => { |
| 6 | + // the intent of this test is to evaluate when a user doesn't provide an array, hence the type assertion |
| 7 | + expect(hasSrcDirectoryInclude('src' as unknown as string[], 'src')).toBe(false); |
| 8 | + }); |
| 9 | + |
| 10 | + it('returns `false` for an empty array', () => { |
| 11 | + expect(hasSrcDirectoryInclude([], 'src/')).toBe(false); |
| 12 | + }); |
| 13 | + |
| 14 | + it('returns `false` when an entry does not exist in the array', () => { |
| 15 | + expect(hasSrcDirectoryInclude(['src'], 'source')).toBe(false); |
| 16 | + }); |
| 17 | + |
| 18 | + it('returns `true` when an entry does exist in the array', () => { |
| 19 | + expect(hasSrcDirectoryInclude(['src', 'foo'], 'src')).toBe(true); |
| 20 | + }); |
| 21 | + |
| 22 | + it('returns `true` for globs', () => { |
| 23 | + expect(hasSrcDirectoryInclude(['src/**/*.ts', 'foo/'], 'src/**/*.ts')).toBe(true); |
| 24 | + }); |
| 25 | + |
| 26 | + it.each([ |
| 27 | + [['src'], './src'], |
| 28 | + [['./src'], 'src'], |
| 29 | + [['../src'], '../src'], |
| 30 | + [['*'], './*'], |
| 31 | + ])('returns `true` for relative paths', (includedPaths, srcDir) => { |
| 32 | + expect(hasSrcDirectoryInclude(includedPaths, srcDir)).toBe(true); |
| 33 | + }); |
| 34 | + }); |
| 35 | +}); |
0 commit comments