From 852f6eeb22be4f9980da6cca6e367b65ca3d5ba7 Mon Sep 17 00:00:00 2001 From: Antoine Chalifour Date: Thu, 3 Oct 2019 13:23:11 +0200 Subject: [PATCH] fix: improve jest mock typings --- src/components/ActionBar/ActionBar.test.tsx | 4 +--- src/components/Engines/Engines.test.tsx | 5 +---- src/components/Repository/Repository.test.tsx | 5 +---- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/components/ActionBar/ActionBar.test.tsx b/src/components/ActionBar/ActionBar.test.tsx index fac80e0..b77c026 100644 --- a/src/components/ActionBar/ActionBar.test.tsx +++ b/src/components/ActionBar/ActionBar.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { mount } from 'enzyme'; import { ActionBar } from './ActionBar'; -const mockPackageMeta = jest.fn(() => ({ +const mockPackageMeta: jest.Mock = jest.fn(() => ({ latest: { homepage: 'https://verdaccio.tld', bugs: { @@ -32,7 +32,6 @@ describe(' component', () => { }); test('when there is no action bar data', () => { - // @ts-ignore mockPackageMeta.mockImplementation(() => ({ latest: {}, })); @@ -44,7 +43,6 @@ describe(' component', () => { }); test('when there is a button to download a tarball', () => { - // @ts-ignore mockPackageMeta.mockImplementation(() => ({ latest: { dist: { diff --git a/src/components/Engines/Engines.test.tsx b/src/components/Engines/Engines.test.tsx index 4756588..c59bb8b 100644 --- a/src/components/Engines/Engines.test.tsx +++ b/src/components/Engines/Engines.test.tsx @@ -5,7 +5,7 @@ import Engine from './Engines'; jest.mock('./img/node.png', () => ''); jest.mock('../Install/img/npm.svg', () => ''); -const mockPackageMeta = jest.fn(() => ({ +const mockPackageMeta: jest.Mock = jest.fn(() => ({ latest: { homepage: 'https://verdaccio.tld', bugs: { @@ -38,7 +38,6 @@ describe(' component', () => { }, }; - // @ts-ignore mockPackageMeta.mockImplementation(() => packageMeta); const wrapper = mount(); @@ -50,7 +49,6 @@ describe(' component', () => { latest: {}, }; - // @ts-ignore mockPackageMeta.mockImplementation(() => packageMeta); const wrapper = mount(); @@ -64,7 +62,6 @@ describe(' component', () => { }, }; - // @ts-ignore mockPackageMeta.mockImplementation(() => packageMeta); const wrapper = mount(); diff --git a/src/components/Repository/Repository.test.tsx b/src/components/Repository/Repository.test.tsx index fafdf7b..ca9204a 100644 --- a/src/components/Repository/Repository.test.tsx +++ b/src/components/Repository/Repository.test.tsx @@ -4,7 +4,7 @@ import Repository from './Repository'; jest.mock('./img/git.png', () => ''); -const mockPackageMeta = jest.fn(() => ({ +const mockPackageMeta: jest.Mock = jest.fn(() => ({ latest: { homepage: 'https://verdaccio.tld', bugs: { @@ -37,7 +37,6 @@ describe(' component', () => { }, }; - // @ts-ignore mockPackageMeta.mockImplementation(() => packageMeta); const wrapper = mount(); @@ -49,7 +48,6 @@ describe(' component', () => { latest: {}, }; - // @ts-ignore mockPackageMeta.mockImplementation(() => packageMeta); const wrapper = mount(); @@ -66,7 +64,6 @@ describe(' component', () => { }, }; - // @ts-ignore mockPackageMeta.mockImplementation(() => packageMeta); const wrapper = mount();