import { ConsoleOutputAdapter } from '../../src/logging/ConsoleOutputAdapter' ; import * as chai from 'chai' ; import * as sinon from 'sinon' ; import * as sinonChai from 'sinon-chai' ; import { LogType } from '../../src/logging/OutputAdapter' ; chai . should ( ) ; chai . use ( sinonChai ) ; describe ( 'ConsoleOutputAdapter' , ( ) => { const outputAdapter = ConsoleOutputAdapter . instance ( ) ; let sandbox ; beforeEach ( async ( ) => { sandbox = sinon . createSandbox ( ) ; } ) ; afterEach ( async ( ) => { sandbox . restore ( ) ; } ) ; describe ( '#log' , ( ) => { it ( 'should log to the console' , ( ) => { const consoleLogStub = sandbox . stub ( console , 'log' ) ; outputAdapter . log ( LogType . INFO , 'hello' , 'hello world' ) ; consoleLogStub . should . have . been . calledTwice ; consoleLogStub . firstCall . should . have . been . calledWithExactly ( 'hello' ) ; consoleLogStub . secondCall . should . have . been . calledWithExactly ( 'hello world' ) ; } ) ; it ( 'should log to the console with no popup' , ( ) => { const consoleLogStub = sandbox . stub ( console , 'log' ) ; outputAdapter . log ( LogType . INFO , undefined , 'hello' ) ; consoleLogStub . should . have . been . calledOnceWithExactly ( 'hello' ) ; } ) ; it ( 'should log to the console with no output' , ( ) => { const consoleLogStub = sandbox . stub ( console , 'log' ) ; outputAdapter . log ( LogType . INFO , 'hello' ) ; consoleLogStub . should . have . been . calledOnceWithExactly ( 'hello' ) ; } ) ; it ( 'should log to the error console' , ( ) => { const consoleLogStub = sandbox . stub ( console , 'error' ) ; outputAdapter . log ( LogType . ERROR , 'hello' , 'hello world' ) ; consoleLogStub . should . have . been . calledTwice ; consoleLogStub . firstCall . should . have . been . calledWithExactly ( 'hello' ) ; consoleLogStub . should . have . been . calledWithExactly ( 'hello world' ) ; } ) ; it ( 'should log to the error console with no popup' , ( ) => { const consoleLogStub = sandbox . stub ( console , 'error' ) ; outputAdapter . log ( LogType . ERROR , undefined , 'hello' ) ; consoleLogStub . should . have . been . calledOnceWithExactly ( 'hello' ) ; } ) ; it ( 'should log to the error console with no output' , ( ) => { const consoleLogStub = sandbox . stub ( console , 'error' ) ; outputAdapter . log ( LogType . ERROR , 'hello' ) ; consoleLogStub . should . have . been . calledOnce ; consoleLogStub . firstCall . should . have . been . calledWithExactly ( 'hello' ) ; } ) ; it ( 'should log to the error console with stack trace' , ( ) => { const consoleLogStub = sandbox . stub ( console , 'error' ) ; outputAdapter . log ( LogType . ERROR , 'hello' , undefined , 'error' ) ; consoleLogStub . should . have . been . calledTwice ; consoleLogStub . firstCall . should . have . been . calledWithExactly ( 'hello' ) ; consoleLogStub . secondCall . should . have . been . calledWithExactly ( 'error' ) ; } ) ; } ) ; } ) ;