Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
fix: improve jest mock typings
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Chalifour authored and antoinechalifour committed Oct 6, 2019
1 parent b1804d7 commit 852f6ee
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/components/ActionBar/ActionBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -32,7 +32,6 @@ describe('<ActionBar /> component', () => {
});

test('when there is no action bar data', () => {
// @ts-ignore
mockPackageMeta.mockImplementation(() => ({
latest: {},
}));
Expand All @@ -44,7 +43,6 @@ describe('<ActionBar /> component', () => {
});

test('when there is a button to download a tarball', () => {
// @ts-ignore
mockPackageMeta.mockImplementation(() => ({
latest: {
dist: {
Expand Down
5 changes: 1 addition & 4 deletions src/components/Engines/Engines.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -38,7 +38,6 @@ describe('<Engines /> component', () => {
},
};

// @ts-ignore
mockPackageMeta.mockImplementation(() => packageMeta);

const wrapper = mount(<Engine />);
Expand All @@ -50,7 +49,6 @@ describe('<Engines /> component', () => {
latest: {},
};

// @ts-ignore
mockPackageMeta.mockImplementation(() => packageMeta);

const wrapper = mount(<Engine />);
Expand All @@ -64,7 +62,6 @@ describe('<Engines /> component', () => {
},
};

// @ts-ignore
mockPackageMeta.mockImplementation(() => packageMeta);

const wrapper = mount(<Engine />);
Expand Down
5 changes: 1 addition & 4 deletions src/components/Repository/Repository.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -37,7 +37,6 @@ describe('<Repository /> component', () => {
},
};

// @ts-ignore
mockPackageMeta.mockImplementation(() => packageMeta);

const wrapper = mount(<Repository />);
Expand All @@ -49,7 +48,6 @@ describe('<Repository /> component', () => {
latest: {},
};

// @ts-ignore
mockPackageMeta.mockImplementation(() => packageMeta);

const wrapper = mount(<Repository />);
Expand All @@ -66,7 +64,6 @@ describe('<Repository /> component', () => {
},
};

// @ts-ignore
mockPackageMeta.mockImplementation(() => packageMeta);

const wrapper = mount(<Repository />);
Expand Down

0 comments on commit 852f6ee

Please sign in to comment.