-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathgetSubscriptions.vnext.test.ts
More file actions
34 lines (27 loc) · 1.21 KB
/
getSubscriptions.vnext.test.ts
File metadata and controls
34 lines (27 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { getSubscriptionsVNext } from '../index.js';
import { mockGetSubscriptionsVNext } from 'tests/__fixtures__/subscriptions/index.mjs';
import client from '../../helpers/client/index.js';
import fixtures from '../__fixtures__/getSubscriptions.vnext.fixtures.js';
import join from 'proper-url-join';
import mswServer from '../../../tests/mswServer.js';
describe('getSubscriptionsVNext', () => {
const expectedConfig = undefined;
const spy = jest.spyOn(client, 'get');
const defaultUrl = join('/marketing/vNext/Subscriptions', {
query: mockGetSubscriptionsVNext.query,
});
it('should handle a client request successfully', async () => {
mswServer.use(fixtures.success(mockGetSubscriptionsVNext.response));
await expect(
getSubscriptionsVNext(mockGetSubscriptionsVNext.query),
).resolves.toEqual(mockGetSubscriptionsVNext.response);
expect(spy).toHaveBeenCalledWith(defaultUrl, expectedConfig);
});
it('should receive a client request error', async () => {
mswServer.use(fixtures.failure());
await expect(
getSubscriptionsVNext(mockGetSubscriptionsVNext.query),
).rejects.toMatchSnapshot();
expect(spy).toHaveBeenCalledWith(defaultUrl, expectedConfig);
});
});