diff --git a/test/scripts/console/index.js b/test/scripts/console/index.js index 2c9a1d2208..94ef2ffd02 100644 --- a/test/scripts/console/index.js +++ b/test/scripts/console/index.js @@ -14,4 +14,5 @@ describe('Console', () => { require('./list_categories'); require('./list_tags'); require('./list_page'); + require('./list_route'); }); diff --git a/test/scripts/console/list_route.js b/test/scripts/console/list_route.js new file mode 100644 index 0000000000..ae3892884b --- /dev/null +++ b/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'); + }); +});