Skip to content

Commit

Permalink
Rename mock type
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket committed Nov 3, 2020
1 parent 8c89551 commit 77d6342
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions tests/helpers/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { UserProfile, UserProvider } from '../../src';

type FetchMock = {
type FetchUserMock = {
ok: boolean;
json: (() => Promise<UserProfile>) | undefined;
};
Expand All @@ -22,12 +22,12 @@ export const withUser = (user: UserProfile | null) => {
);
};

export const fetchUserMock = (): FetchMock => ({
export const fetchUserMock = (): FetchUserMock => ({
ok: true,
json: (): Promise<UserProfile> => Promise.resolve(user)
});

export const fetchUserFailureMock = (): FetchMock => ({
export const fetchUserFailureMock = (): FetchUserMock => ({
ok: false,
json: undefined
});
2 changes: 0 additions & 2 deletions tests/hooks/use-user.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { fetchUserMock, fetchUserFailureMock, withUser, user } from '../helpers/

describe('context wrapper', () => {
test('should use the initial user', async () => {
(global as any).fetch = fetchUserMock;

const { result } = renderHook(() => useUser(), { wrapper: withUser(user) });

expect(result.current.user).toEqual(user);
Expand Down

0 comments on commit 77d6342

Please sign in to comment.