@@ -41,6 +41,8 @@ describe('cli', () => {
4141
4242 describe ( 'spinners' , ( ) => {
4343 beforeEach ( ( ) => {
44+ stream = new LogStream ( ) ;
45+ cli = new CLI ( stream ) ;
4446 cli . startSpinner ( 'foo' ) ;
4547 } ) ;
4648
@@ -59,20 +61,34 @@ describe('cli', () => {
5961 } ) ;
6062
6163 describe ( 'write' , ( ) => {
64+ beforeEach ( ( ) => {
65+ stream = new LogStream ( ) ;
66+ cli = new CLI ( stream ) ;
67+ } ) ;
6268 it ( 'should write in stream' , ( ) => {
69+ const stream = new LogStream ( ) ;
70+ const cli = new CLI ( stream ) ;
6371 cli . write ( 'Getting commits...' ) ;
64- assert . strictEqual ( logResult ( ) , 'Getting commits...' ) ;
72+ assert . strictEqual ( strip ( stream . toString ( ) ) , 'Getting commits...' ) ;
6573 } ) ;
6674 } ) ;
6775
6876 describe ( 'log' , ( ) => {
77+ beforeEach ( ( ) => {
78+ stream = new LogStream ( ) ;
79+ cli = new CLI ( stream ) ;
80+ } ) ;
6981 it ( 'should write in stream' , ( ) => {
7082 cli . log ( 'Getting commits...' ) ;
7183 assert . strictEqual ( logResult ( ) , 'Getting commits...\n' ) ;
7284 } ) ;
7385 } ) ;
7486
7587 describe ( 'table' , ( ) => {
88+ beforeEach ( ( ) => {
89+ stream = new LogStream ( ) ;
90+ cli = new CLI ( stream ) ;
91+ } ) ;
7692 it ( 'should print the first element with bold style and padding' , ( ) => {
7793 cli . table ( 'Title' , 'description' ) ;
7894 assert . strictEqual ( logResult ( ) ,
@@ -81,6 +97,10 @@ describe('cli', () => {
8197 } ) ;
8298
8399 describe ( 'separator' , ( ) => {
100+ beforeEach ( ( ) => {
101+ stream = new LogStream ( ) ;
102+ cli = new CLI ( stream ) ;
103+ } ) ;
84104 it ( 'should print a separator line with the specified text' , ( ) => {
85105 cli . separator ( 'Separator' ) ;
86106 assert . strictEqual (
@@ -106,6 +126,10 @@ describe('cli', () => {
106126 } ) ;
107127
108128 describe ( 'ok' , ( ) => {
129+ beforeEach ( ( ) => {
130+ stream = new LogStream ( ) ;
131+ cli = new CLI ( stream ) ;
132+ } ) ;
109133 it ( 'should print a success message' , ( ) => {
110134 cli . ok ( 'Perfect!' ) ;
111135 assert . strictEqual ( logResult ( ) , ` ${ success } Perfect!\n` ) ;
@@ -119,6 +143,10 @@ describe('cli', () => {
119143 } ) ;
120144
121145 describe ( 'warn' , ( ) => {
146+ beforeEach ( ( ) => {
147+ stream = new LogStream ( ) ;
148+ cli = new CLI ( stream ) ;
149+ } ) ;
122150 it ( 'should print a warning message' , ( ) => {
123151 cli . warn ( 'Warning!' ) ;
124152 assert . strictEqual ( logResult ( ) , ` ${ warning } Warning!\n` ) ;
@@ -132,6 +160,10 @@ describe('cli', () => {
132160 } ) ;
133161
134162 describe ( 'info' , ( ) => {
163+ beforeEach ( ( ) => {
164+ stream = new LogStream ( ) ;
165+ cli = new CLI ( stream ) ;
166+ } ) ;
135167 it ( 'should print an info message' , ( ) => {
136168 cli . info ( 'Info!' ) ;
137169 assert . strictEqual ( logResult ( ) , ` ${ info } Info!\n` ) ;
@@ -144,6 +176,10 @@ describe('cli', () => {
144176 } ) ;
145177
146178 describe ( 'error' , ( ) => {
179+ beforeEach ( ( ) => {
180+ stream = new LogStream ( ) ;
181+ cli = new CLI ( stream ) ;
182+ } ) ;
147183 it ( 'should print an error message' , ( ) => {
148184 cli . error ( 'Error!' ) ;
149185 assert . strictEqual ( logResult ( ) , ` ${ error } Error!\n` ) ;
@@ -184,6 +220,7 @@ describe('cli', () => {
184220 questionType : cli . QUESTION_TYPE . INPUT
185221 } ) ;
186222 assert . strictEqual ( cli . spinner . isSpinning , true ) ;
223+ cli . stopSpinner ( 'foo' ) ;
187224 } ) ;
188225 } ) ;
189226
0 commit comments