Skip to content

Commit

Permalink
test(#4344): add a unit test case
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Mar 28, 2022
1 parent ba81258 commit 80fb693
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/scripts/console/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,46 @@ describe('new', () => {
await unlink(path);
});

it('path - number (issue #4334)', async () => {
const date = moment(now);
const path = join(hexo.source_dir, '_posts', '404.md');
const body = [
'title: Page not found',
'date: ' + date.format('YYYY-MM-DD HH:mm:ss'),
'tags:',
'---'
].join('\n') + '\n';

await n({
_: ['Page not found'],
path: 404
});
const content = await readFile(path);
content.should.eql(body);

await unlink(path);
});

it('path - hexadecimal number', async () => {
const date = moment(now);
const path = join(hexo.source_dir, '_posts', '0x400.md');
const body = [
'title: test',
'date: ' + date.format('YYYY-MM-DD HH:mm:ss'),
'tags:',
'---'
].join('\n') + '\n';

await n({
_: ['test'],
path: 0x400
});
const content = await readFile(path);
content.should.eql(body);

await unlink(path);
});

it('rename if target existed', async () => {
const path = join(hexo.source_dir, '_posts', 'Hello-World-1.md');

Expand Down

0 comments on commit 80fb693

Please sign in to comment.