forked from parcel-bundler/parcel
/
config.test.js
50 lines (46 loc) 路 1.16 KB
/
config.test.js
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
// @flow strict-local
import assert from 'assert';
import {loadConfig} from '../src/config';
import {inputFS as fs} from '@parcel/test-utils';
import path from 'path';
describe('loadConfig', () => {
it('load config with json', async () => {
assert.deepEqual(
(
await loadConfig(
fs,
path.join(__dirname, './input/config/config.json'),
['config.json'],
path.join(__dirname, './input/config/'),
)
)?.config,
{
hoge: 'fuga',
},
);
});
it('should throw error with empty string json', async () => {
// $FlowFixMe[prop-missing]
await assert.rejects(async () => {
await loadConfig(
fs,
path.join(__dirname, './input/config/empty.json'),
['empty.json'],
path.join(__dirname, './input/config/'),
);
});
});
it('should load with empty string config toml', async () => {
assert.deepEqual(
(
await loadConfig(
fs,
path.join(__dirname, './input/config/empty.toml'),
['empty.toml'],
path.join(__dirname, './input/config/'),
)
)?.config,
{},
);
});
});