Skip to content

Commit

Permalink
fix: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Pcrab committed Jun 14, 2023
1 parent 87fb1bd commit 8f0f694
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/scripts/hexo/load_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ describe('Load plugins', () => {
'}'
].join('\n');

const asyncScript = [
'async function afunc() {',
' return new Promise(resolve => resolve());',
'}',
'await afunc()',
'hexo._script_test = {',
' filename: __filename,',
' dirname: __dirname,',
' module: module,',
' require: require',
'}'
].join('\n');
function validate(path) {
const result = hexo._script_test;

Expand Down Expand Up @@ -81,6 +93,19 @@ describe('Load plugins', () => {
});
});

it('load async plugins', () => {
const name = 'hexo-async-plugin-test';
const path = join(hexo.plugin_dir, name, 'index.js');

return Promise.all([
createPackageFile(name),
fs.writeFile(path, asyncScript)
]).then(() => loadPlugins(hexo)).then(() => {
validate(path);
return fs.unlink(path);
});
});

it('load scoped plugins', () => {
const name = '@some-scope/hexo-plugin-test';
const path = join(hexo.plugin_dir, name, 'index.js');
Expand Down

0 comments on commit 8f0f694

Please sign in to comment.