|
1 | | -import { expect } from 'vitest'; |
2 | | -import { pluginConfigSchema } from '@code-pushup/models'; |
3 | | -import { AUDITS, GROUPS } from './constants.js'; |
4 | | -import { typescriptPlugin } from './typescript-plugin.js'; |
| 1 | +import {expect} from 'vitest'; |
| 2 | +import {pluginConfigSchema} from '@code-pushup/models'; |
| 3 | +import {AUDITS, GROUPS} from './constants.js'; |
| 4 | +import {typescriptPlugin} from './typescript-plugin.js'; |
| 5 | +import type {TypescriptPluginOptions} from "./types"; |
5 | 6 |
|
6 | 7 | describe('typescriptPlugin-config-object', () => { |
7 | | - it('should create valid plugin config without options', async () => { |
8 | | - const pluginConfig = await typescriptPlugin(); |
| 8 | + it('should create valid plugin config without options', async () => { |
| 9 | + const pluginConfig = await typescriptPlugin(); |
9 | 10 |
|
10 | | - expect(() => pluginConfigSchema.parse(pluginConfig)).not.toThrow(); |
| 11 | + expect(() => pluginConfigSchema.parse(pluginConfig)).not.toThrow(); |
11 | 12 |
|
12 | | - const { audits, groups } = pluginConfig; |
13 | | - expect(audits).toHaveLength(AUDITS.length); |
14 | | - expect(groups).toBeDefined(); |
15 | | - expect(groups!).toHaveLength(GROUPS.length); |
16 | | - }); |
17 | | - |
18 | | - it('should create valid plugin config', async () => { |
19 | | - const pluginConfig = await typescriptPlugin({ |
20 | | - tsConfigPath: 'mocked-away/tsconfig.json', |
21 | | - onlyAudits: ['syntax-errors', 'semantic-errors', 'configuration-errors'], |
| 13 | + const {audits, groups} = pluginConfig; |
| 14 | + expect(audits).toHaveLength(AUDITS.length); |
| 15 | + expect(groups).toBeDefined(); |
| 16 | + expect(groups!).toHaveLength(GROUPS.length); |
22 | 17 | }); |
23 | 18 |
|
24 | | - expect(() => pluginConfigSchema.parse(pluginConfig)).not.toThrow(); |
| 19 | + it('should create valid plugin config', async () => { |
| 20 | + const pluginConfig = await typescriptPlugin({ |
| 21 | + tsconfig: 'mocked-away/tsconfig.json', |
| 22 | + onlyAudits: ['syntax-errors', 'semantic-errors', 'configuration-errors'], |
| 23 | + }); |
| 24 | + |
| 25 | + expect(() => pluginConfigSchema.parse(pluginConfig)).not.toThrow(); |
25 | 26 |
|
26 | | - const { audits, groups } = pluginConfig; |
27 | | - expect(audits).toHaveLength(3); |
28 | | - expect(groups).toBeDefined(); |
29 | | - expect(groups!).toHaveLength(2); |
30 | | - }); |
| 27 | + const {audits, groups} = pluginConfig; |
| 28 | + expect(audits).toHaveLength(3); |
| 29 | + expect(groups).toBeDefined(); |
| 30 | + expect(groups!).toHaveLength(2); |
| 31 | + }); |
| 32 | + |
| 33 | + it('should throw for invalid valid params', async () => { |
| 34 | + await expect(() => typescriptPlugin({ |
| 35 | + tsconfig: 42 |
| 36 | + } as unknown as TypescriptPluginOptions)).rejects.toThrow(/invalid_type/); |
| 37 | + }); |
31 | 38 | }); |
0 commit comments