Skip to content

Commit 68b32fe

Browse files
committed
fix
1 parent 34964ac commit 68b32fe

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ tmp/
66
.nyc_output/
77
.vscode/
88
dist/
9-
package-lock.json
9+
package-lock.json
10+
coverage/

test/scripts/hexo.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import chai from 'chai';
22
import sinon from 'sinon';
33
import proxyquire from 'proxyquire';
4+
import { writeFile, unlink, rmdir } from 'hexo-fs';
5+
import { join } from 'path';
46
chai.should();
57

68
require('chai').should();
@@ -50,7 +52,23 @@ describe('hexo', () => {
5052

5153
it('should watch SIGINT signal');
5254

53-
it('load hexo module in current folder');
55+
it('load hexo module in current folder', async () => {
56+
const spy = sinon.spy();
57+
const baseDir = join(__dirname, 'find_pkg_test');
58+
const pkgPath = join(baseDir, 'package.json');
59+
60+
await writeFile(pkgPath, '{"hexo": {}}');
61+
const hexo = proxyquire('../../dist/hexo', {
62+
'./console'(ctx) {
63+
ctx.extend.console.register('help', spy);
64+
}
65+
});
66+
67+
await hexo(baseDir, {_: []});
68+
spy.calledOnce.should.be.true;
69+
await unlink(pkgPath);
70+
await rmdir(baseDir);
71+
});
5472

5573
it('load hexo module in parent folder recursively');
5674

test/scripts/init.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,32 @@ describe('init', () => {
7979
await check(join(baseDir, 'test'));
8080
}));
8181

82-
it('unconventional path', () => withoutSpawn(async () => {
82+
it('unconventional path - 0x', () => withoutSpawn(async () => {
8383
await init({_: ['0x400']});
8484
await check(join(baseDir, '0x400'));
85+
}));
8586

87+
it('unconventional path - 0b', () => withoutSpawn(async () => {
8688
await init({_: ['0b101']});
8789
await check(join(baseDir, '0b101'));
90+
}));
8891

92+
it('unconventional path - 0o', () => withoutSpawn(async () => {
8993
await init({_: ['0o71']});
9094
await check(join(baseDir, '0o71'));
95+
}));
9196

97+
it('unconventional path - undefined', () => withoutSpawn(async () => {
9298
await init({_: ['undefined']});
9399
await check(join(baseDir, 'undefined'));
100+
}));
94101

102+
it('unconventional path - null', () => withoutSpawn(async () => {
95103
await init({_: ['null']});
96104
await check(join(baseDir, 'null'));
105+
}));
97106

107+
it('unconventional path - true', () => withoutSpawn(async () => {
98108
await init({_: ['true']});
99109
await check(join(baseDir, 'true'));
100110
}));

0 commit comments

Comments
 (0)