Skip to content

Commit e59ed18

Browse files
committed
test: Address CodeRabbit feedback on REST helpers and analytics spec
Guard undefined response data in find/count helpers and fix grammar in the analytics spec description.
1 parent 748d5d1 commit e59ed18

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

spec/helpers/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export async function find<T = any>(
9696
body: { ...params, _method: 'GET' },
9797
auth,
9898
});
99-
return (res.data as { results: T[] }).results;
99+
return (res.data as { results: T[] } | undefined)?.results ?? [];
100100
}
101101

102102
/** Count matching objects (count=1, limit=0). Returns the count. */
@@ -111,5 +111,5 @@ export async function count(
111111
body: { ...params, count: 1, limit: 0, _method: 'GET' },
112112
auth,
113113
});
114-
return (res.data as { count: number }).count;
114+
return (res.data as { count: number } | undefined)?.count ?? 0;
115115
}

spec/server/analytics.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('AnalyticsController', () => {
2020
expect(args[1]).toEqual({ dimensions: { key: 'value', count: '0' } });
2121
});
2222

23-
it('should track a app opened event', async () => {
23+
it('should track an app opened event', async () => {
2424
const appOpenedSpy = spyOn(analyticsAdapter, 'appOpened').and.callThrough();
2525
await reconfigureServer({ analyticsAdapter });
2626

0 commit comments

Comments
 (0)