-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathoptions_spec.ts
64 lines (52 loc) · 1.75 KB
/
options_spec.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
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { normalizeOptions } from './options';
import { Schema as WtrBuilderSchema } from './schema';
describe('options', () => {
describe('normalizeOptions()', () => {
const GOLDEN_SCHEMA: WtrBuilderSchema = {
include: ['**/included/*.ts'],
exclude: ['**/excluded/*.ts'],
tsConfig: './tsconfig.json',
};
it('requires include and exclude properties', () => {
const options = normalizeOptions({
...GOLDEN_SCHEMA,
include: ['**/*.ts'],
exclude: ['**/*.d.ts'],
});
expect(options).toContain({
include: ['**/*.ts'],
exclude: ['**/*.d.ts'],
});
// @ts-expect-error `undefined` should not be in the `include` type.
options.include = undefined;
// @ts-expect-error `undefined` should not be in the `exclude` type.
options.exclude = undefined;
});
it('normalizes polyfills', () => {
const stringPolyfillOptions = normalizeOptions({
...GOLDEN_SCHEMA,
polyfills: './polyfills.ts',
});
expect(stringPolyfillOptions.polyfills).toEqual(['./polyfills.ts']);
const arrayPolyfillOptions = normalizeOptions({
...GOLDEN_SCHEMA,
polyfills: ['./first.ts', './second.ts'],
});
expect(arrayPolyfillOptions.polyfills).toEqual(['./first.ts', './second.ts']);
});
it('passes through other options', () => {
const options = normalizeOptions({
...GOLDEN_SCHEMA,
assets: ['./path/to/file.txt'],
});
expect(options.assets).toEqual(['./path/to/file.txt']);
});
});
});