|
1 | 1 | import fetch from 'jest-fetch-mock';
|
2 |
| -import { fetchOnce } from '../common/utils/test-utils'; |
| 2 | +import { fetchOnce, fetchSearchParams } from '../common/utils/test-utils'; |
3 | 3 | import { Event, EventResponse, ListResponse } from '../common/interfaces';
|
4 | 4 | import { WorkOS } from '../workos';
|
5 | 5 | import { ConnectionType } from '../sso/interfaces';
|
@@ -50,11 +50,43 @@ describe('Event', () => {
|
50 | 50 | data: [eventResponse],
|
51 | 51 | list_metadata: {},
|
52 | 52 | };
|
| 53 | + describe('with options', () => { |
| 54 | + it('requests Events with query parameters', async () => { |
| 55 | + const eventsResponse: ListResponse<EventResponse> = { |
| 56 | + object: 'list', |
| 57 | + data: [eventResponse], |
| 58 | + list_metadata: {}, |
| 59 | + }; |
| 60 | + |
| 61 | + fetchOnce(eventsResponse); |
| 62 | + |
| 63 | + const list = await workos.events.listEvents({ |
| 64 | + events: ['connection.activated'], |
| 65 | + rangeStart: '2020-05-04', |
| 66 | + rangeEnd: '2020-05-07', |
| 67 | + }); |
| 68 | + |
| 69 | + expect(fetchSearchParams()).toMatchObject({ |
| 70 | + events: 'connection.activated', |
| 71 | + range_start: '2020-05-04', |
| 72 | + range_end: '2020-05-07', |
| 73 | + }); |
| 74 | + |
| 75 | + expect(list).toEqual({ |
| 76 | + object: 'list', |
| 77 | + data: [event], |
| 78 | + listMetadata: {}, |
| 79 | + }); |
| 80 | + }); |
| 81 | + }); |
53 | 82 |
|
54 | 83 | it(`requests Events`, async () => {
|
55 | 84 | fetchOnce(eventsListResponse);
|
56 | 85 |
|
57 |
| - const subject = await workos.events.listEvents({}); |
| 86 | + const subject = await workos.events.listEvents({ |
| 87 | + rangeStart: '2020-05-05', |
| 88 | + rangeEnd: '2020-05-07', |
| 89 | + }); |
58 | 90 |
|
59 | 91 | expect(subject).toEqual({
|
60 | 92 | object: 'list',
|
|
0 commit comments