Skip to content

Commit

Permalink
test(list_route): improve coverage (#5097)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang authored Nov 6, 2022
1 parent 871ac4f commit bec4e6e
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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 bec4e6e

Please sign in to comment.