@@ -26,7 +26,7 @@ jest.unstable_mockModule('formdata-node/file-from-path', () => ({
2626
2727// The module being tested should be imported dynamically. This ensures that the
2828// mocks are used in place of any actual dependencies.
29- const { run } = await import ( '../src/main.ts' )
29+ const { run, formatPumpRoomResponse } = await import ( '../src/main.ts' )
3030
3131describe ( 'main.ts' , ( ) => {
3232 const mockRootDir = '/mock/root/dir'
@@ -67,10 +67,19 @@ describe('main.ts', () => {
6767 }
6868 } )
6969
70- // Set up axios mock
70+ // Set up axios mock with the expected response format
7171 axios . post . mockResolvedValue ( {
7272 status : 200 ,
73- data : { success : true }
73+ data : {
74+ repo_updated : true ,
75+ pushed_at : '2025-07-30T21:26:10.875969' ,
76+ tasks_current : 33 ,
77+ tasks_updated : 33 ,
78+ tasks_created : 0 ,
79+ tasks_deleted : 1 ,
80+ tasks_cached : 33 ,
81+ tasks_synchronized_with_cms : 2
82+ }
7483 } )
7584
7685 // Set up FormData mock
@@ -93,6 +102,38 @@ describe('main.ts', () => {
93102
94103 // Verify success message was logged
95104 expect ( core . info ) . toHaveBeenCalled ( )
105+
106+ // Since we're mocking the API response and not actually calling the real API,
107+ // we can't directly test the formatted output in this test.
108+ // The formatting functionality is tested separately in the "Formats the API response correctly" test.
109+ } )
110+
111+ it ( 'Formats the API response correctly' , ( ) => {
112+ // Create a sample response object
113+ const sampleResponse = {
114+ repo_updated : true ,
115+ pushed_at : '2025-07-30T21:26:10.875969' ,
116+ tasks_current : 33 ,
117+ tasks_updated : 33 ,
118+ tasks_created : 0 ,
119+ tasks_deleted : 1 ,
120+ tasks_cached : 33 ,
121+ tasks_synchronized_with_cms : 2
122+ }
123+
124+ // Format the response
125+ const formattedResponse = formatPumpRoomResponse ( sampleResponse )
126+
127+ // Verify the formatted response contains the expected information
128+ expect ( formattedResponse ) . toContain ( 'PumpRoom Repository Update Summary' )
129+ expect ( formattedResponse ) . toContain ( 'Repository Updated: Yes' )
130+ expect ( formattedResponse ) . toContain ( 'Tasks Summary' )
131+ expect ( formattedResponse ) . toContain ( 'Current: 33' )
132+ expect ( formattedResponse ) . toContain ( 'Updated: 33' )
133+ expect ( formattedResponse ) . toContain ( 'Created: 0' )
134+ expect ( formattedResponse ) . toContain ( 'Deleted: 1' )
135+ expect ( formattedResponse ) . toContain ( 'Cached: 33' )
136+ expect ( formattedResponse ) . toContain ( 'Synchronized with CMS: 2' )
96137 } )
97138
98139 it ( 'Handles API error correctly' , async ( ) => {
0 commit comments