-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2722 from CAFECA-IO/feature/report
Feature/ Mock report
- Loading branch information
Showing
13 changed files
with
521 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { z } from 'zod'; | ||
import { IZodValidator } from '@/interfaces/zod_validator'; | ||
import { zodTimestampInSecondsNoDefault } from '@/lib/utils/zod_schema/common'; | ||
import { FinancialReportTypesKey } from '@/interfaces/report_type'; | ||
|
||
const reportGetQueryValidatorV2 = z.object({ | ||
startDate: zodTimestampInSecondsNoDefault(), | ||
endDate: zodTimestampInSecondsNoDefault(), | ||
language: z.string(), | ||
reportType: z.nativeEnum(FinancialReportTypesKey), | ||
}); | ||
|
||
const reportGetBodyValidatorV2 = z.object({}); | ||
|
||
export const reportGetValidatorV2: IZodValidator< | ||
(typeof reportGetQueryValidatorV2)['shape'], | ||
(typeof reportGetBodyValidatorV2)['shape'] | ||
> = { | ||
query: reportGetQueryValidatorV2, | ||
body: reportGetBodyValidatorV2, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { NextApiRequest, NextApiResponse } from 'next'; | ||
import { handleGetRequest } from '@/pages/api/v2/company/[companyId]/report/index'; | ||
import { STATUS_MESSAGE } from '@/constants/status_code'; | ||
|
||
import { FinancialReportTypesKey } from '@/interfaces/report_type'; | ||
|
||
let req: jest.Mocked<NextApiRequest>; | ||
let res: jest.Mocked<NextApiResponse>; | ||
|
||
jest.mock('../../../../../../lib/utils/session.ts', () => ({ | ||
getSession: jest.fn().mockResolvedValue({ | ||
userId: 1001, | ||
companyId: 1001, | ||
}), | ||
})); | ||
|
||
jest.mock('../../../../../../lib/utils/auth_check', () => ({ | ||
checkAuthorization: jest.fn().mockResolvedValue(true), | ||
})); | ||
|
||
// Info: (20241007 - Murky) Uncomment this to check zod return | ||
// jest.mock('../../../../../../lib/utils/logger_back', () => ({ | ||
// loggerRequest: jest.fn().mockReturnValue({ | ||
// info: jest.fn(), | ||
// error: jest.fn(), | ||
// }), | ||
// })); | ||
|
||
beforeEach(() => { | ||
req = { | ||
headers: {}, | ||
query: {}, | ||
method: '', | ||
socket: {}, | ||
json: jest.fn(), | ||
} as unknown as jest.Mocked<NextApiRequest>; | ||
|
||
res = { | ||
status: jest.fn().mockReturnThis(), | ||
json: jest.fn(), | ||
} as unknown as jest.Mocked<NextApiResponse>; | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe('company/[companyId]/certificate', () => { | ||
describe('GET Certificate List', () => { | ||
it('should match patter', async () => { | ||
req.query = { | ||
startDate: '10000000', | ||
endDate: '16000000', | ||
language: 'zh', | ||
reportType: FinancialReportTypesKey.balance_sheet, | ||
}; | ||
req.body = {}; | ||
|
||
const { payload, statusMessage } = await handleGetRequest(req, res); | ||
|
||
expect(statusMessage).toBe(STATUS_MESSAGE.SUCCESS_GET); | ||
expect(payload).toBeDefined(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.