Skip to content

Commit

Permalink
test(list_route): improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Nov 5, 2022
1 parent 871ac4f commit d9d5a90
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/scripts/console/index.js
Expand Up @@ -14,4 +14,5 @@ describe('Console', () => {
require('./list_categories');
require('./list_tags');
require('./list_page');
require('./list_route');
});
31 changes: 31 additions & 0 deletions test/scripts/console/list_route.js
@@ -0,0 +1,31 @@
'use strict';

const { stub, assert: sinonAssert } = require('sinon');

describe('Console list', () => {
const Hexo = require('../../../lib/hexo');
const hexo = new Hexo(__dirname);

const listRoutes = require('../../../lib/plugins/console/list/route').bind(hexo);
const { route } = hexo;

let logStub;

before(() => { logStub = stub(console, 'log'); });

afterEach(() => { logStub.reset(); });

after(() => { logStub.restore(); });

it('no route', () => {
listRoutes();
sinonAssert.calledWithMatch(logStub, 'Total: 0');
});

it('route', async () => {
route.set('test', 'foo');

listRoutes();
sinonAssert.calledWithMatch(logStub, 'Total: 1');
});
});

0 comments on commit d9d5a90

Please sign in to comment.