2020-11-08 09:20:02 -05:00
|
|
|
import { parseConfigFile } from '../src';
|
2021-04-25 03:08:14 -05:00
|
|
|
import { parseConfigurationFile } from './utils';
|
2020-11-08 09:20:02 -05:00
|
|
|
|
|
|
|
describe('Package access utilities', () => {
|
|
|
|
describe('JSON format', () => {
|
|
|
|
test('parse default.json', () => {
|
|
|
|
const config = parseConfigFile(parseConfigurationFile('default.json'));
|
|
|
|
|
|
|
|
expect(config.storage).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('parse invalid.json', () => {
|
|
|
|
expect(function () {
|
|
|
|
parseConfigFile(parseConfigurationFile('invalid.json'));
|
2021-09-08 12:06:37 -05:00
|
|
|
}).toThrow(/CONFIG: it does not look like a valid config file/);
|
2020-11-08 09:20:02 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('parse not-exists.json', () => {
|
|
|
|
expect(function () {
|
|
|
|
parseConfigFile(parseConfigurationFile('not-exists.json'));
|
2021-09-08 12:06:37 -05:00
|
|
|
}).toThrow(/Cannot find module/);
|
2020-11-08 09:20:02 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('JavaScript format', () => {
|
|
|
|
test('parse default.js', () => {
|
|
|
|
const config = parseConfigFile(parseConfigurationFile('default.js'));
|
|
|
|
|
|
|
|
expect(config.storage).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('parse invalid.js', () => {
|
|
|
|
expect(function () {
|
|
|
|
parseConfigFile(parseConfigurationFile('invalid.js'));
|
2021-09-08 12:06:37 -05:00
|
|
|
}).toThrow(/CONFIG: it does not look like a valid config file/);
|
2020-11-08 09:20:02 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('parse not-exists.js', () => {
|
|
|
|
expect(function () {
|
|
|
|
parseConfigFile(parseConfigurationFile('not-exists.js'));
|
2021-09-08 12:06:37 -05:00
|
|
|
}).toThrow(/Cannot find module/);
|
2020-11-08 09:20:02 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|