-
Notifications
You must be signed in to change notification settings - Fork 34
/
validate.test.ts
91 lines (74 loc) · 2.02 KB
/
validate.test.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import {describe, test, expect} from 'vitest';
import validate from '../validate.js';
describe('validate', () => {
test('empty', () => {
expect(() => validate({})).not.toThrow();
});
test('uses pass', () => {
expect(() => validate({build: {uses: ['antd']}})).not.toThrow();
});
test('uses invalid value', () => {
expect(() => validate({build: {uses: ['unwanted']}})).toThrow();
});
test('additional properties', () => {
const settings = {
foo: 'bar',
};
expect(() => validate(settings)).toThrow();
});
test('additional properties in build', () => {
const settings = {
build: {
foo: 'bar',
},
};
expect(() => validate(settings)).toThrow();
});
test('additional properties in devServer', () => {
const settings = {
devServer: {
foo: 'bar',
},
};
expect(() => validate(settings)).toThrow();
});
test('invalid plugins', () => {
const settings = {
plugins: [
{},
123,
421412,
],
};
expect(() => validate(settings)).toThrow();
});
test('feature matrix', () => {
const settings = {
featureMatrix: {
stable: {
track: false,
date: '2020-06-01',
},
dev: {
track: true,
date: '2020-07-01',
},
},
};
expect(() => validate(settings)).not.toThrow();
});
test('plugin array', () => {
const settings = {
plugins: [
() => ({}),
],
};
expect(() => validate(settings)).not.toThrow();
});
test('plugin factory', () => {
const settings = {
plugins: () => [],
};
expect(() => validate(settings)).not.toThrow();
});
});