All files / core/use-cases display-environment-versions.spec.ts

100% Statements 29/29
100% Branches 0/0
100% Functions 7/7
100% Lines 26/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 561x   1x   1x 1x   1x     1x 3x     1x 3x     1x 1x     1x 1x     1x 1x 1x       1x     1x 1x 1x     1x     1x 1x 1x 1x     1x            
import { ts } from 'ts-morph';
 
const sinon = require('sinon');
 
import Logger from '../../infrastructure/logging/logger';
import DisplayEnvironmentVersions from './display-environment-versions';
 
describe('Use-cases - Display informations', () => {
    let consoleStubLog;
 
    beforeEach(() => {
        consoleStubLog = sinon.stub(console, 'log');
    });
 
    afterEach(() => {
        consoleStubLog.restore();
    });
 
    after(() => {
        process.chdir('../../../');
    });
 
    it('without --silent', async () => {
        DisplayEnvironmentVersions.display({
            version: '3.4.0'
        });
        sinon.assert.calledWith(console.log, '3.4.0');
        sinon.assert.calledWith(console.log, sinon.match('Node.js version'));
        sinon.assert.calledWith(
            console.log,
            sinon.match(`TypeScript version used by Compodoc : ${ts.version}`)
        );
        sinon.assert.calledWith(console.log, sinon.match('Operating system'));
    });
 
    it('with --silent', async () => {
        Logger.silent = true;
        DisplayEnvironmentVersions.display({
            version: '3.4.0'
        });
        sinon.assert.calledWithExactly(console.log, 'Compodoc v3.4.0');
    });
 
    it('with real project', async () => {
        Logger.silent = false;
        process.chdir('./test/fixtures/todomvc-ng2');
        DisplayEnvironmentVersions.display({
            version: '3.4.0'
        });
        sinon.assert.calledWithExactly(
            console.log,
            'TypeScript version of current project : 3.1.1'
        );
    });
});