/
githubmirror
/
hexo
Обзор
Документация
Войти
/
githubmirror
/
hexo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/scripts/console/list.ts
50 строк
2 KB
D-Sketon
refactor: refactor types & support warehouse6 (#5483)
22 янв 2025, 10:05
Не верифицирован
22 янв 2025, 10:05
70efca7
Код
Авторство
О чём код?
import { spy, stub, assert as sinonAssert, SinonSpy } from 'sinon'; import BluebirdPromise from 'bluebird'; import Hexo from '../../../lib/hexo'; import listConsole from '../../../lib/plugins/console/list'; type OriginalParams = Parameters<typeof listConsole>; type OriginalReturn = ReturnType<typeof listConsole>; describe('Console list', () => { const hexo = new Hexo(__dirname); it('no args', () => { hexo.call = spy(); const list: (...args: OriginalParams) => OriginalReturn = listConsole.bind(hexo); list({ _: [''] }); (hexo.call as SinonSpy).calledOnce.should.be.true; (hexo.call as SinonSpy).args[0][0].should.eql('help'); (hexo.call as SinonSpy).args[0][1]._[0].should.eql('list'); }); it('has args', async () => { const logStub = stub(console, 'log'); hexo.load = () => BluebirdPromise.resolve(); const list: (...args: OriginalParams) => OriginalReturn = listConsole.bind(hexo); await list({ _: ['page'] }); sinonAssert.calledWithMatch(logStub, 'Date'); sinonAssert.calledWithMatch(logStub, 'Title'); sinonAssert.calledWithMatch(logStub, 'Path'); sinonAssert.calledWithMatch(logStub, 'No pages.'); logStub.restore(); }); it('list type not found', () => { hexo.call = spy(); const list: (...args: OriginalParams) => OriginalReturn = listConsole.bind(hexo); list({ _: ['test'] }); (hexo.call as SinonSpy).calledOnce.should.be.true; (hexo.call as SinonSpy).args[0][0].should.eql('help'); (hexo.call as SinonSpy).args[0][1]._[0].should.eql('list'); }); });