2016-11-11 12:17:01 +01:00
|
|
|
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' });
|
2016-11-29 16:16:56 -02:00
|
|
|
}).toThrowError('Error in configuration file: A `media_folder` wasn\'t found. Check your config.yml file.');
|
2016-11-11 12:17:01 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
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',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|