Skip to content

Commit d6cd714

Browse files
author
nebarf
committed
Finalize http client specs
1 parent c75ee0a commit d6cd714

10 files changed

+390
-84
lines changed

src/__tests__/fixtures/http-client-config-provider.fixture.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import React, { ReactElement } from 'react';
22
import { HttpClientConfigProvider, HttpClientProviderConfig } from '../..';
33

44
export class HttpClientProviderConfigFixture {
5-
static defaultOptions: Partial<HttpClientProviderConfig<undefined>> = {};
6-
7-
static create<HttpRequestBodyT = void>(
8-
options?: Partial<HttpClientProviderConfig<HttpRequestBodyT>>
5+
static create<HttpRequestBodyT = void, HttpResponseT = unknown>(
6+
options: Partial<HttpClientProviderConfig<HttpRequestBodyT, HttpResponseT>> = {}
97
): ({ children }: { children: ReactElement }) => ReactElement {
10-
const fallenbackOptions: Partial<HttpClientProviderConfig<HttpRequestBodyT>> =
11-
options || HttpClientProviderConfigFixture.defaultOptions;
8+
const fallenbackOptions: Partial<HttpClientProviderConfig<HttpRequestBodyT, HttpResponseT>> =
9+
options;
1210

1311
return ({ children }: { children: ReactElement }): ReactElement => {
1412
const Provider = (
Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
1+
import { cleanup } from '@testing-library/react';
2+
// import { renderHook } from '@testing-library/react-hooks';
3+
import { FetchMock } from 'jest-fetch-mock';
4+
5+
const fetch = global.fetch as FetchMock;
6+
17
describe('http-client-config-provider', () => {
2-
test('', () => {
3-
expect(1).toBe(1);
8+
// const fetchResponse = {
9+
// name: 'Phelony',
10+
// role: 'Admin',
11+
// };
12+
13+
beforeEach(() => {
14+
jest.useFakeTimers();
15+
jest.spyOn(global, 'setTimeout');
416
});
17+
18+
afterEach((): void => {
19+
cleanup();
20+
fetch.resetMocks();
21+
jest.runAllTimers();
22+
});
23+
24+
// test('should override global req options', async () => {});
25+
26+
// test('should override global base url', async () => {});
27+
28+
// test('should override cache store', async () => {});
29+
30+
// test('should override cache store prefix', async () => {});
31+
32+
// test('should override cache store separator', async () => {});
533
});

0 commit comments

Comments
 (0)