-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathcore-config.spec.ts
More file actions
55 lines (48 loc) · 1.87 KB
/
core-config.spec.ts
File metadata and controls
55 lines (48 loc) · 1.87 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { describe, expect, it } from 'vitest';
import { config } from '../../test';
import { coreConfigSchema } from './core-config';
/*
- plugin slug: es-lint
- audit slug: no-any
- group slug: basics
- audit: no-any
- category: best-practices
- from category to audit: es-lint#no-any
- from category to group: es-lint#group:basics
*/
describe('CoreConfig', () => {
it('should parse if configuration is valid', () => {
const coreConfig = config();
expect(() => coreConfigSchema.parse(coreConfig)).not.toThrow();
});
it('should throw if the category slugs are not unique', () => {
const coreConfig = config();
const duplicatedSlug = coreConfig.categories[0].slug;
coreConfig.categories = [
...coreConfig.categories,
coreConfig.categories[0],
];
expect(() => coreConfigSchema.parse(coreConfig)).toThrow(
`In the categories, the following slugs are duplicated: ${duplicatedSlug}`,
);
});
it('should throw if ref in a category does not exist in audits', () => {
const coreConfig = config();
const ref = coreConfig.categories[1].refs[0];
const pluginSlug = ref.plugin;
const missingAuditSlug = 'missing-audit-ref';
ref.slug = missingAuditSlug;
expect(() => coreConfigSchema.parse(coreConfig)).toThrow(
`In the categories, the following plugin refs do not exist in the provided plugins: ${pluginSlug}/${missingAuditSlug}`,
);
});
it('should throw if ref in a category does not exist in groups', () => {
const coreConfig = config();
const categoryConfig = coreConfig.categories[0];
const ref = { ...categoryConfig.refs[0], slug: 'missing-slug' };
coreConfig.categories[1].refs.push(ref);
expect(() => coreConfigSchema.parse(coreConfig)).toThrow(
`In the categories, the following plugin refs do not exist in the provided plugins: lighthouse#missing-slug (group)`,
);
});
});