|
1 | 1 | import { createParseSettings } from '../../src/parseSettings/createParseSettings';
|
2 | 2 |
|
| 3 | +const projectService = { service: true }; |
| 4 | + |
| 5 | +jest.mock('../../src/create-program/createProjectService', () => ({ |
| 6 | + createProjectService: (): typeof projectService => projectService, |
| 7 | +})); |
| 8 | + |
3 | 9 | describe('createParseSettings', () => {
|
| 10 | + describe('EXPERIMENTAL_projectService', () => { |
| 11 | + it('is created when options.EXPERIMENTAL_useProjectService is enabled', () => { |
| 12 | + process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER = 'false'; |
| 13 | + |
| 14 | + const parseSettings = createParseSettings('', { |
| 15 | + EXPERIMENTAL_useProjectService: true, |
| 16 | + }); |
| 17 | + |
| 18 | + expect(parseSettings.EXPERIMENTAL_projectService).toBe(projectService); |
| 19 | + }); |
| 20 | + |
| 21 | + it('is created when options.EXPERIMENTAL_useProjectService is undefined, options.project is true, and process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER is true', () => { |
| 22 | + process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER = 'true'; |
| 23 | + |
| 24 | + const parseSettings = createParseSettings('', { |
| 25 | + EXPERIMENTAL_useProjectService: undefined, |
| 26 | + project: true, |
| 27 | + }); |
| 28 | + |
| 29 | + expect(parseSettings.EXPERIMENTAL_projectService).toBe(projectService); |
| 30 | + }); |
| 31 | + |
| 32 | + it('is not created when options.EXPERIMENTAL_useProjectService is undefined, options.project is falsy, and process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER is true', () => { |
| 33 | + process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER = 'true'; |
| 34 | + |
| 35 | + const parseSettings = createParseSettings('', { |
| 36 | + EXPERIMENTAL_useProjectService: undefined, |
| 37 | + }); |
| 38 | + |
| 39 | + expect(parseSettings.EXPERIMENTAL_projectService).toBeUndefined(); |
| 40 | + }); |
| 41 | + |
| 42 | + it('is not created when options.EXPERIMENTAL_useProjectService is false, options.project is true, and process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER is true', () => { |
| 43 | + process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER = 'true'; |
| 44 | + |
| 45 | + const parseSettings = createParseSettings('', { |
| 46 | + EXPERIMENTAL_useProjectService: false, |
| 47 | + project: true, |
| 48 | + }); |
| 49 | + |
| 50 | + expect(parseSettings.EXPERIMENTAL_projectService).toBeUndefined(); |
| 51 | + }); |
| 52 | + }); |
| 53 | + |
4 | 54 | describe('tsconfigMatchCache', () => {
|
5 | 55 | it('reuses the TSConfig match cache when called a subsequent time', () => {
|
6 | 56 | const parseSettings1 = createParseSettings('input.ts');
|
|
0 commit comments