@@ -5,7 +5,7 @@ import { useConsoleSpy } from '../../__setup__/hooks/useConsoleSpy.js';
55
66useAuthSetup ( ) ;
77
8- const { lastErrorMessage, logSpy , errorSpy } = useConsoleSpy ( ) ;
8+ const { lastErrorMessage, logMessages , errorSpy } = useConsoleSpy ( ) ;
99
1010describe ( '[api] apify api' , ( ) => {
1111 it ( 'should fail when not logged in' , async ( ) => {
@@ -23,11 +23,9 @@ describe('[api] apify api', () => {
2323 args_methodOrEndpoint : 'v2/users/me' ,
2424 } ) ;
2525
26- const spy = logSpy ( ) ;
27- expect ( spy ) . toHaveBeenCalled ( ) ;
26+ expect ( logMessages . log . length ) . toBeGreaterThan ( 0 ) ;
2827
29- const output = spy . mock . calls [ 0 ] [ 0 ] ;
30- const parsed = JSON . parse ( output ) ;
28+ const parsed = JSON . parse ( logMessages . log [ 0 ] ) ;
3129
3230 expect ( parsed . data ) . toBeDefined ( ) ;
3331 expect ( parsed . data . id ) . toBeDefined ( ) ;
@@ -41,11 +39,9 @@ describe('[api] apify api', () => {
4139 args_methodOrEndpoint : '/v2/users/me' ,
4240 } ) ;
4341
44- const spy = logSpy ( ) ;
45- expect ( spy ) . toHaveBeenCalled ( ) ;
42+ expect ( logMessages . log . length ) . toBeGreaterThan ( 0 ) ;
4643
47- const output = spy . mock . calls [ 0 ] [ 0 ] ;
48- const parsed = JSON . parse ( output ) ;
44+ const parsed = JSON . parse ( logMessages . log [ 0 ] ) ;
4945
5046 expect ( parsed . data ) . toBeDefined ( ) ;
5147 expect ( parsed . data . id ) . toBeDefined ( ) ;
@@ -58,11 +54,9 @@ describe('[api] apify api', () => {
5854 args_methodOrEndpoint : 'users/me' ,
5955 } ) ;
6056
61- const spy = logSpy ( ) ;
62- expect ( spy ) . toHaveBeenCalled ( ) ;
57+ expect ( logMessages . log . length ) . toBeGreaterThan ( 0 ) ;
6358
64- const output = spy . mock . calls [ 0 ] [ 0 ] ;
65- const parsed = JSON . parse ( output ) ;
59+ const parsed = JSON . parse ( logMessages . log [ 0 ] ) ;
6660
6761 expect ( parsed . data ) . toBeDefined ( ) ;
6862 expect ( parsed . data . id ) . toBeDefined ( ) ;
@@ -90,11 +84,9 @@ describe('[api] apify api', () => {
9084 flags_header : 'X-Custom-Test:hello' ,
9185 } ) ;
9286
93- const spy = logSpy ( ) ;
94- expect ( spy ) . toHaveBeenCalled ( ) ;
87+ expect ( logMessages . log . length ) . toBeGreaterThan ( 0 ) ;
9588
96- const output = spy . mock . calls [ 0 ] [ 0 ] ;
97- const parsed = JSON . parse ( output ) ;
89+ const parsed = JSON . parse ( logMessages . log [ 0 ] ) ;
9890
9991 expect ( parsed . data . id ) . toBeDefined ( ) ;
10092 } ) ;
@@ -107,11 +99,9 @@ describe('[api] apify api', () => {
10799 args_endpoint : 'v2/users/me' ,
108100 } ) ;
109101
110- const spy = logSpy ( ) ;
111- expect ( spy ) . toHaveBeenCalled ( ) ;
102+ expect ( logMessages . log . length ) . toBeGreaterThan ( 0 ) ;
112103
113- const output = spy . mock . calls [ 0 ] [ 0 ] ;
114- const parsed = JSON . parse ( output ) ;
104+ const parsed = JSON . parse ( logMessages . log [ 0 ] ) ;
115105
116106 expect ( parsed . data ) . toBeDefined ( ) ;
117107 expect ( parsed . data . id ) . toBeDefined ( ) ;
@@ -126,11 +116,9 @@ describe('[api] apify api', () => {
126116 flags_params : JSON . stringify ( { limit : 1 , desc : true } ) ,
127117 } ) ;
128118
129- const spy = logSpy ( ) ;
130- expect ( spy ) . toHaveBeenCalled ( ) ;
119+ expect ( logMessages . log . length ) . toBeGreaterThan ( 0 ) ;
131120
132- const output = spy . mock . calls [ 0 ] [ 0 ] ;
133- const parsed = JSON . parse ( output ) ;
121+ const parsed = JSON . parse ( logMessages . log [ 0 ] ) ;
134122
135123 expect ( parsed . data ) . toBeDefined ( ) ;
136124 expect ( parsed . data . items ) . toBeDefined ( ) ;
@@ -151,11 +139,9 @@ describe('[api] apify api', () => {
151139 flags_body : JSON . stringify ( { name : actorName , title : 'Test API Command' } ) ,
152140 } ) ;
153141
154- const spy = logSpy ( ) ;
155- expect ( spy ) . toHaveBeenCalled ( ) ;
142+ expect ( logMessages . log . length ) . toBeGreaterThan ( 0 ) ;
156143
157- const output = spy . mock . calls [ 0 ] [ 0 ] ;
158- const parsed = JSON . parse ( output ) ;
144+ const parsed = JSON . parse ( logMessages . log [ 0 ] ) ;
159145
160146 expect ( parsed . data ) . toBeDefined ( ) ;
161147 expect ( parsed . data . name ) . toBe ( actorName ) ;
0 commit comments