@@ -8,32 +8,27 @@ import { LogLevel, Logger } from '@github-manager/utils/Logger';
88import '@test-suite/globals' ;
99
1010describe ( 'Logger' , ( ) => {
11- let logSpy : SinonSpy < [ message : string ] , void > ;
12- let logErrorSpy : SinonSpy < [ e : unknown , message : string ] , void > ;
11+ let logSpy : SinonSpy < [ message ?: unknown , ...addtionalPamaraters : unknown [ ] ] , void > ;
1312
1413 const getUserDataDirStub : SinonStub < [ ] , string > = stub ( GLib , 'get_user_data_dir' ) ;
1514 const newForPathStub : SinonStub < [ path : string ] , Gio . File > = stub ( Gio . File , 'new_for_path' ) ;
1615
1716 before ( ( ) => {
18- logSpy = spy ( globalThis , 'log' ) ;
19- logErrorSpy = spy ( globalThis , 'logError' ) ;
17+ logSpy = spy ( globalThis . console , 'log' ) ;
2018 Logger . domain = 'TestSuite' ;
2119 } ) ;
2220
2321 beforeEach ( ( ) => {
2422 Logger . resetConfiguration ( ) ;
2523
2624 logSpy . resetHistory ( ) ;
27- logErrorSpy . resetHistory ( ) ;
2825
2926 newForPathStub . reset ( ) ;
3027 getUserDataDirStub . reset ( ) ;
3128 } ) ;
3229
3330 after ( ( ) => {
3431 logSpy . restore ( ) ;
35- logErrorSpy . restore ( ) ;
36-
3732 newForPathStub . restore ( ) ;
3833 getUserDataDirStub . restore ( ) ;
3934 } ) ;
@@ -104,25 +99,22 @@ describe('Logger', () => {
10499
105100 // Single error argument
106101 logger . warn ( 'Log entry with an error' , error ) ;
107- assert . isTrue ( logSpy . notCalled ) ;
108- assert . isTrue ( logErrorSpy . calledOnce ) ;
109- assert . isTrue ( logErrorSpy . calledWithExactly ( error , '[TestSuite] Logger.test WARN Log entry with an error' ) ) ;
102+ assert . isTrue ( logSpy . calledOnce ) ;
103+ assert . isTrue ( logSpy . calledWithExactly ( '[TestSuite] Logger.test WARN Log entry with an error' , error ) ) ;
110104
111105 // Error argument with other format arguments
112106 logger . error ( 'Unable to get item #{0} due to {1}' , 65 , 'E_DUPLICATE_KEY' , error ) ;
113- assert . isTrue ( logSpy . notCalled ) ;
114- assert . isTrue ( logErrorSpy . calledTwice ) ;
107+ assert . isTrue ( logSpy . calledTwice ) ;
115108 assert . isTrue (
116- logErrorSpy . calledWithExactly (
117- error ,
118- '[TestSuite] Logger.test ERROR Unable to get item #65 due to E_DUPLICATE_KEY'
109+ logSpy . calledWithExactly (
110+ '[TestSuite] Logger.test ERROR Unable to get item #65 due to E_DUPLICATE_KEY' ,
111+ error
119112 )
120113 ) ;
121114
122115 // Error argument as string
123116 logger . error ( 'Unable to get item #{0} due to {1}' , 65 , 'E_DUPLICATE_KEY' , 'Error text' ) ;
124- assert . isTrue ( logSpy . calledOnce ) ;
125- assert . isTrue ( logErrorSpy . calledTwice ) ;
117+ assert . isTrue ( logSpy . callCount === 3 ) ;
126118 assert . isTrue (
127119 logSpy . calledWithExactly (
128120 '[TestSuite] Logger.test ERROR Unable to get item #65 due to E_DUPLICATE_KEY - Error text'
@@ -132,11 +124,10 @@ describe('Logger', () => {
132124 // Error argument as object
133125 const errorObject = { toString : ( ) => 'Error in object' } ;
134126 logger . error ( 'Unable to get item #{0} due to {1}' , 65 , 'E_DUPLICATE_KEY' , errorObject ) ;
135- assert . isTrue ( logSpy . calledTwice ) ;
136- assert . isTrue ( logErrorSpy . calledTwice ) ;
127+ assert . isTrue ( logSpy . callCount === 4 ) ;
137128 assert . isTrue (
138129 logSpy . calledWithExactly (
139- '[TestSuite] Logger.test ERROR Unable to get item #65 due to E_DUPLICATE_KEY - Additional object of type object: Error in object'
130+ '[TestSuite] Logger.test ERROR Unable to get item #65 due to E_DUPLICATE_KEY - Error of type object: Error in object'
140131 )
141132 ) ;
142133 } ) ;
0 commit comments