Skip to content

Commit d23f6d9

Browse files
committed
Improve test coverage
1 parent 19c7eb5 commit d23f6d9

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

packages/backend/src/api/__tests__/EnterpriseConnectionApi.test.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,72 @@ describe('EnterpriseConnectionAPI', () => {
120120
});
121121
});
122122
});
123+
124+
describe('getEnterpriseConnectionList', () => {
125+
it('successfully fetches enterprise connections', async () => {
126+
const mockListResponse = {
127+
data: [mockEnterpriseConnectionResponse],
128+
total_count: 1,
129+
};
130+
131+
server.use(
132+
http.get(
133+
'https://api.clerk.test/v1/enterprise_connections',
134+
validateHeaders(({ request }) => {
135+
const url = new URL(request.url);
136+
expect(url.searchParams.get('organization_id')).toBe('org_123');
137+
expect(url.searchParams.get('active')).toBe('true');
138+
expect(url.searchParams.get('limit')).toBe('10');
139+
expect(url.searchParams.get('offset')).toBe('0');
140+
return HttpResponse.json(mockListResponse);
141+
}),
142+
),
143+
);
144+
145+
const response = await apiClient.enterpriseConnections.getEnterpriseConnectionList({
146+
organizationId: 'org_123',
147+
active: true,
148+
limit: 10,
149+
offset: 0,
150+
});
151+
152+
expect(response.data).toHaveLength(1);
153+
expect(response.data[0].id).toBe('entconn_123');
154+
expect(response.data[0].name).toBe('Clerk');
155+
expect(response.totalCount).toBe(1);
156+
});
157+
});
158+
159+
describe('getEnterpriseConnection', () => {
160+
it('successfully fetches a single enterprise connection', async () => {
161+
server.use(
162+
http.get(
163+
'https://api.clerk.test/v1/enterprise_connections/entconn_123',
164+
validateHeaders(() => HttpResponse.json(mockEnterpriseConnectionResponse)),
165+
),
166+
);
167+
168+
const response = await apiClient.enterpriseConnections.getEnterpriseConnection('entconn_123');
169+
170+
expect(response.id).toBe('entconn_123');
171+
expect(response.name).toBe('Clerk');
172+
expect(response.domains).toEqual(['clerk.dev']);
173+
});
174+
});
175+
176+
describe('deleteEnterpriseConnection', () => {
177+
it('successfully deletes an enterprise connection', async () => {
178+
server.use(
179+
http.delete(
180+
'https://api.clerk.test/v1/enterprise_connections/entconn_123',
181+
validateHeaders(() => HttpResponse.json(mockEnterpriseConnectionResponse)),
182+
),
183+
);
184+
185+
const response = await apiClient.enterpriseConnections.deleteEnterpriseConnection('entconn_123');
186+
187+
expect(response.id).toBe('entconn_123');
188+
expect(response.name).toBe('Clerk');
189+
});
190+
});
123191
});

0 commit comments

Comments
 (0)