Skip to content

Commit

Permalink
test(load_config): process external_link
Browse files Browse the repository at this point in the history
Default config should apply when undefined
  • Loading branch information
SukkaW committed Jul 15, 2020
1 parent 2e5d944 commit a4bbd82
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions test/scripts/hexo/load_config.js
Expand Up @@ -107,20 +107,27 @@ describe('Load config', () => {
});

// Deprecated: config.external_link boolean option will be removed in future
it('migrate external_link config from boolean to object', async () => {
const content1 = 'external_link: true';
const content2 = 'external_link: false';
it('migrate external_link config from boolean to object - true', async () => {
const content = 'external_link: true';

try {
await writeFile(hexo.config_path, content1);
await writeFile(hexo.config_path, content);
await loadConfig(hexo);
hexo.config.external_link.should.eql({
enable: true,
field: 'site',
exclude: []
});
} finally {
await unlink(hexo.config_path);
}
});

it('migrate external_link config from boolean to object - false', async () => {
const content = 'external_link: false';

await writeFile(hexo.config_path, content2);
try {
await writeFile(hexo.config_path, content);
await loadConfig(hexo);
hexo.config.external_link.should.eql({
enable: false,
Expand All @@ -132,6 +139,18 @@ describe('Load config', () => {
}
});

it('migrate external_link config from boolean to object - undefined', async () => {
try {
// Test undefined
await writeFile(hexo.config_path, '');

await loadConfig(hexo);
hexo.config.external_link.should.eql(defaultConfig.external_link);
} finally {
await unlink(hexo.config_path);
}
});

it('custom public_dir', async () => {
try {
await writeFile(hexo.config_path, 'public_dir: foo');
Expand Down

0 comments on commit a4bbd82

Please sign in to comment.