62 lines
1.7 KiB
JavaScript
62 lines
1.7 KiB
JavaScript
|
import * as config from '../config';
|
||
|
|
||
|
describe('config', () => {
|
||
|
describe('applyDefaults', () => {
|
||
|
it('should throw if media_folder is not defined in config', () => {
|
||
|
expect(() => {
|
||
|
config.applyDefaults({ foo: 'bar' });
|
||
|
}).toThrowError('Config: `media_folder` setting could not be found in config.');
|
||
|
});
|
||
|
|
||
|
it('should set publish_mode if not set', () => {
|
||
|
expect(config.applyDefaults({
|
||
|
foo: 'bar',
|
||
|
media_folder: 'path/to/media',
|
||
|
})).toEqual({
|
||
|
foo: 'bar',
|
||
|
publish_mode: 'simple',
|
||
|
media_folder: 'path/to/media',
|
||
|
public_folder: '/path/to/media',
|
||
|
});
|
||
|
});
|
||
|
|
||
|
it('should set publish_mode from config', () => {
|
||
|
expect(config.applyDefaults({
|
||
|
foo: 'bar',
|
||
|
publish_mode: 'complex',
|
||
|
media_folder: 'path/to/media',
|
||
|
})).toEqual({
|
||
|
foo: 'bar',
|
||
|
publish_mode: 'complex',
|
||
|
media_folder: 'path/to/media',
|
||
|
public_folder: '/path/to/media',
|
||
|
});
|
||
|
});
|
||
|
|
||
|
it('should set public_folder based on media_folder if not set', () => {
|
||
|
expect(config.applyDefaults({
|
||
|
foo: 'bar',
|
||
|
media_folder: 'path/to/media',
|
||
|
})).toEqual({
|
||
|
foo: 'bar',
|
||
|
publish_mode: 'simple',
|
||
|
media_folder: 'path/to/media',
|
||
|
public_folder: '/path/to/media',
|
||
|
});
|
||
|
});
|
||
|
|
||
|
it('should not overwrite public_folder if set', () => {
|
||
|
expect(config.applyDefaults({
|
||
|
foo: 'bar',
|
||
|
media_folder: 'path/to/media',
|
||
|
public_folder: '/publib/path',
|
||
|
})).toEqual({
|
||
|
foo: 'bar',
|
||
|
publish_mode: 'simple',
|
||
|
media_folder: 'path/to/media',
|
||
|
public_folder: '/publib/path',
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|