Skip to content

Commit 56a88a7

Browse files
committed
chore: Update tests
1 parent 0ff650a commit 56a88a7

File tree

3 files changed

+18
-26
lines changed

3 files changed

+18
-26
lines changed

app/src/tests/adapters/ReportAdapter.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ describe('ReportAdapter', () => {
2424

2525
// Then
2626
expect(result).toEqual({
27-
reportId: mockReportMetadata.id,
27+
reportId: String(mockReportMetadata.id),
28+
countryId: mockReportMetadata.country_id,
29+
apiVersion: mockReportMetadata.api_version,
2830
simulationIds: [mockReportMetadata.simulation_1_id, mockReportMetadata.simulation_2_id],
2931
status: mockReportMetadata.status,
3032
output: mockReportOutput,
@@ -42,10 +44,12 @@ describe('ReportAdapter', () => {
4244

4345
// Then
4446
expect(result).toEqual({
45-
reportId: mockReportMetadataSingleSimulation.id,
47+
reportId: String(mockReportMetadataSingleSimulation.id),
48+
countryId: mockReportMetadataSingleSimulation.country_id,
49+
apiVersion: mockReportMetadataSingleSimulation.api_version,
4650
simulationIds: [mockReportMetadataSingleSimulation.simulation_1_id],
4751
status: mockReportMetadataSingleSimulation.status,
48-
output: mockReportMetadataSingleSimulation.output,
52+
output: null,
4953
createdAt: mockReportMetadataSingleSimulation.created_at,
5054
updatedAt: mockReportMetadataSingleSimulation.updated_at,
5155
});
@@ -213,6 +217,7 @@ describe('ReportAdapter', () => {
213217

214218
// Then
215219
expect(result).toEqual({
220+
id: 2,
216221
status: expectedErrorStatus,
217222
output: expectedNullOutput,
218223
});

app/src/tests/fixtures/adapters/reportMocks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const mockReportOutput: ReportOutput = {
1515
};
1616

1717
export const mockReport: Report = {
18-
reportId: 'report-123',
18+
reportId: '123',
1919
countryId: 'us',
2020
apiVersion: 'v1',
2121
simulationIds: ['sim-456', 'sim-789'],
@@ -26,7 +26,7 @@ export const mockReport: Report = {
2626
};
2727

2828
export const mockPendingReport: Report = {
29-
reportId: 'report-pending-001',
29+
reportId: '1',
3030
countryId: 'us',
3131
apiVersion: 'v1',
3232
simulationIds: ['sim-111'],
@@ -37,7 +37,7 @@ export const mockPendingReport: Report = {
3737
};
3838

3939
export const mockErrorReport: Report = {
40-
reportId: 'report-error-002',
40+
reportId: '2',
4141
countryId: 'us',
4242
apiVersion: 'v1',
4343
simulationIds: ['sim-222', 'sim-333'],

app/src/tests/unit/api/report.test.ts

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ describe('report API', () => {
4040
Accept: 'application/json',
4141
},
4242
});
43-
expect(result).toEqual({
44-
...mockReportMetadata,
45-
id: String(mockReportMetadata.id),
46-
});
43+
expect(result).toEqual(mockReportMetadata);
4744
});
4845

4946
test('given API error then throws error', async () => {
@@ -68,7 +65,7 @@ describe('report API', () => {
6865
// Given
6966
const countryId = 'us';
7067
const payload = mockReportCreationPayload;
71-
const mockApiResponse = { result: { id: 123 } };
68+
const mockApiResponse = { result: mockReportMetadata };
7269
const mockResponse = {
7370
ok: true,
7471
json: vi.fn().mockResolvedValue(mockApiResponse),
@@ -84,7 +81,7 @@ describe('report API', () => {
8481
headers: { 'Content-Type': 'application/json' },
8582
body: JSON.stringify(payload),
8683
});
87-
expect(result).toEqual({ result: { id: '123' } });
84+
expect(result).toEqual(mockReportMetadata);
8885
});
8986

9087
test('given API error then throws error', async () => {
@@ -118,17 +115,12 @@ describe('report API', () => {
118115
const result = await markReportCompleted(countryId, reportId, mockReport);
119116

120117
// Then
121-
expect(global.fetch).toHaveBeenCalledWith(`${BASE_URL}/${countryId}/report/${reportId}`, {
118+
expect(global.fetch).toHaveBeenCalledWith(`${BASE_URL}/${countryId}/report`, {
122119
method: 'PATCH',
123120
headers: { 'Content-Type': 'application/json' },
124121
body: JSON.stringify(mockCompletedReportPayload),
125122
});
126-
expect(result).toEqual({
127-
result: {
128-
...mockReportMetadata,
129-
id: String(mockReportMetadata.id),
130-
},
131-
});
123+
expect(result).toEqual(mockReportMetadata);
132124
});
133125

134126
test('given API error then throws error', async () => {
@@ -164,17 +156,12 @@ describe('report API', () => {
164156
const result = await markReportError(countryId, reportId, mockErrorReport);
165157

166158
// Then
167-
expect(global.fetch).toHaveBeenCalledWith(`${BASE_URL}/${countryId}/report/${reportId}`, {
159+
expect(global.fetch).toHaveBeenCalledWith(`${BASE_URL}/${countryId}/report`, {
168160
method: 'PATCH',
169161
headers: { 'Content-Type': 'application/json' },
170162
body: JSON.stringify(mockErrorReportPayload),
171163
});
172-
expect(result).toEqual({
173-
result: {
174-
...mockReportMetadata,
175-
id: String(mockReportMetadata.id),
176-
},
177-
});
164+
expect(result).toEqual(mockReportMetadata);
178165
});
179166

180167
test('given API error then throws error', async () => {

0 commit comments

Comments
 (0)