Update jest related packages (#46391)

* Update jest related packages

* use correct type

* adapt spy and describe.each types

* update yarn.lock

* update snapshot

* define types before passing to describe.each
This commit is contained in:
renovate[bot] 2019-09-25 12:00:33 -07:00 committed by Spencer
parent 9abc85efe0
commit 0034293867
22 changed files with 333 additions and 561 deletions

View file

@ -313,7 +313,7 @@
"@types/history": "^4.7.3",
"@types/hoek": "^4.1.3",
"@types/humps": "^1.1.2",
"@types/jest": "^24.0.9",
"@types/jest": "^24.0.18",
"@types/joi": "^13.4.2",
"@types/jquery": "^3.3.6",
"@types/js-yaml": "^3.11.1",
@ -375,7 +375,7 @@
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-ban": "1.2.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jest": "22.7.1",
"eslint-plugin-jest": "22.17.0",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-mocha": "5.3.0",
"eslint-plugin-no-unsanitized": "3.0.2",
@ -403,9 +403,9 @@
"intl-messageformat-parser": "^1.4.0",
"is-path-inside": "^2.1.0",
"istanbul-instrumenter-loader": "3.0.1",
"jest": "^24.8.0",
"jest-cli": "^24.8.0",
"jest-dom": "^3.1.3",
"jest": "^24.9.0",
"jest-cli": "^24.9.0",
"jest-dom": "^3.5.0",
"jest-raw-loader": "^1.0.1",
"jimp": "0.8.4",
"json5": "^1.0.1",

View file

@ -23,7 +23,7 @@
"eslint-plugin-ban": "1.2.0",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jest": "^22.4.1",
"eslint-plugin-jest": "^22.17.0",
"eslint-plugin-mocha": "^5.3.0",
"eslint-plugin-no-unsanitized": "3.0.2",
"eslint-plugin-prefer-object-spread": "1.2.1",

View file

@ -19,7 +19,7 @@
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/plugin-transform-async-to-generator": "^7.5.0",
"jest": "^24.8.0",
"jest": "^24.9.0",
"typescript": "3.5.3"
},
"jest": {

View file

@ -887,7 +887,7 @@ describe('I18n engine', () => {
});
describe('load', () => {
let mockFetch: jest.Mock;
let mockFetch: jest.SpyInstance;
beforeEach(() => {
mockFetch = jest.spyOn(global as any, 'fetch').mockImplementation();
});

View file

@ -17,7 +17,7 @@
},
"homepage": "https://github.com/jbudz/spec-to-console#readme",
"devDependencies": {
"jest": "^24.8.0",
"jest": "^24.9.0",
"prettier": "^1.14.3"
},
"dependencies": {

View file

@ -20,8 +20,11 @@
import { CoreWindow, loadPluginBundle } from './plugin_loader';
let createdScriptTags = [] as any[];
let appendChildSpy: jest.Mock<Node, [Node]>;
let createElementSpy: jest.Mock<HTMLElement, [string, (ElementCreationOptions | undefined)?]>;
let appendChildSpy: jest.SpyInstance<Node, [Node]>;
let createElementSpy: jest.SpyInstance<
HTMLElement,
[string, (ElementCreationOptions | undefined)?]
>;
const coreWindow = (window as unknown) as CoreWindow;

View file

@ -52,7 +52,7 @@ const createSetupContractMock = () => {
route: jest.fn(),
start: jest.fn(),
stop: jest.fn(),
} as unknown) as Server,
} as unknown) as jest.MockedClass<Server>,
createCookieSessionStorageFactory: jest.fn(),
registerOnPreAuth: jest.fn(),
registerAuth: jest.fn(),

View file

@ -20,15 +20,16 @@
import { SavedObjectsClientContract } from '../types';
import { SavedObjectsErrorHelpers } from './lib/errors';
const create = (): jest.Mocked<SavedObjectsClientContract> => ({
errors: SavedObjectsErrorHelpers,
create: jest.fn(),
bulkCreate: jest.fn(),
delete: jest.fn(),
bulkGet: jest.fn(),
find: jest.fn(),
get: jest.fn(),
update: jest.fn(),
});
const create = () =>
(({
errors: SavedObjectsErrorHelpers,
create: jest.fn(),
bulkCreate: jest.fn(),
delete: jest.fn(),
bulkGet: jest.fn(),
find: jest.fn(),
get: jest.fn(),
update: jest.fn(),
} as unknown) as jest.Mocked<SavedObjectsClientContract>);
export const SavedObjectsClientMock = { create };

View file

@ -21,7 +21,7 @@ import { http } from './index_patterns_api_client.test.mock';
import { IndexPatternsApiClient } from './index_patterns_api_client';
describe('IndexPatternsApiClient', () => {
let fetchSpy: jest.Mock;
let fetchSpy: jest.SpyInstance;
let indexPatternsApiClient: IndexPatternsApiClient;
beforeEach(() => {

View file

@ -12,7 +12,7 @@ import { SessionStorageMock } from './SessionStorageMock';
jest.mock('ui/kfetch');
describe('callApi', () => {
let kfetchSpy: jest.Mock;
let kfetchSpy: jest.SpyInstance;
beforeEach(() => {
kfetchSpy = jest.spyOn(kfetchModule, 'kfetch').mockResolvedValue({
@ -63,7 +63,7 @@ describe('callApi', () => {
});
describe('cache', () => {
let nowSpy: jest.Mock;
let nowSpy: jest.SpyInstance;
beforeEach(() => {
nowSpy = mockNow('2019');
});

View file

@ -19,7 +19,7 @@ type TimeStamp = number;
interface Result {
time: TimeStamp;
value: Value;
value: unknown;
}
interface ProcessedResults {

View file

@ -210,26 +210,8 @@ describe('AreaChartWithCustomPrompt', () => {
color: '#490092',
},
],
[
[
{
key: 'uniqueSourceIpsHistogram',
value: [],
color: '#DB1374',
},
{
key: 'uniqueDestinationIpsHistogram',
value: [
{ x: new Date('2019-05-03T13:00:00.000Z').valueOf(), y: 565975 },
{ x: new Date('2019-05-04T01:00:00.000Z').valueOf(), y: 1084366 },
{ x: new Date('2019-05-04T13:00:00.000Z').valueOf(), y: 12280 },
],
color: '#490092',
},
],
],
],
])('renders areachart', (data: ChartSeriesData[] | [] | null | undefined) => {
] as Array<[ChartSeriesData[]]>)('renders areachart', data => {
beforeAll(() => {
shallowWrapper = shallow(
<AreaChartWithCustomPrompt height={customHeight} width={customWidth} data={data} />
@ -321,7 +303,7 @@ describe('AreaChartWithCustomPrompt', () => {
},
],
],
])('renders prompt', (data: ChartSeriesData[] | [] | null | undefined) => {
] as Array<[ChartSeriesData[] | null | undefined]>)('renders prompt', data => {
beforeAll(() => {
shallowWrapper = shallow(
<AreaChartWithCustomPrompt height={customHeight} width={customWidth} data={data} />

View file

@ -219,7 +219,7 @@ describe.each([
});
});
describe.each([
const table: Array<[ChartSeriesData[] | undefined | null]> = [
[],
null,
[
@ -281,7 +281,9 @@ describe.each([
},
],
],
])('renders prompt', (data: ChartSeriesData[] | [] | null | undefined) => {
] as any; // eslint-disable-line @typescript-eslint/no-explicit-any
describe.each(table)('renders prompt', data => {
let shallowWrapper: ShallowWrapper;
beforeAll(() => {
shallowWrapper = shallow(

View file

@ -95,7 +95,7 @@ exports[`JobsTable renders correctly against snapshot 1`] = `
]
}
loading={true}
noItemsMessage={<Memo />}
noItemsMessage={<Memo(NoItemsMessage) />}
onChange={[Function]}
pagination={
Object {

View file

@ -62,38 +62,46 @@ describe('kpiHostsComponent', () => {
});
});
describe.each([
[mockKpiHostsData, kpiHostsMapping],
[mockKpiHostDetailsData, kpiHostDetailsMapping],
])('it should handle KpiHostsProps and KpiHostDetailsProps', (data, mapping) => {
let mockUseKpiMatrixStatus: jest.SpyInstance;
beforeAll(() => {
mockUseKpiMatrixStatus = jest.spyOn(statItems, 'useKpiMatrixStatus');
});
const table = [
[mockKpiHostsData, kpiHostsMapping] as [typeof mockKpiHostsData, typeof kpiHostsMapping],
[mockKpiHostDetailsData, kpiHostDetailsMapping] as [
typeof mockKpiHostDetailsData,
typeof kpiHostDetailsMapping
],
];
beforeEach(() => {
shallow(
<KpiHostsComponent
data={data}
from={from}
id={ID}
loading={false}
to={to}
narrowDateRange={narrowDateRange}
/>
);
});
describe.each(table)(
'it should handle KpiHostsProps and KpiHostDetailsProps',
(data, mapping) => {
let mockUseKpiMatrixStatus: jest.SpyInstance;
beforeAll(() => {
mockUseKpiMatrixStatus = jest.spyOn(statItems, 'useKpiMatrixStatus');
});
afterEach(() => {
mockUseKpiMatrixStatus.mockClear();
});
beforeEach(() => {
shallow(
<KpiHostsComponent
data={data}
from={from}
id={ID}
loading={false}
to={to}
narrowDateRange={narrowDateRange}
/>
);
});
afterAll(() => {
mockUseKpiMatrixStatus.mockRestore();
});
afterEach(() => {
mockUseKpiMatrixStatus.mockClear();
});
test(`it should apply correct mapping by given data type`, () => {
expect(mockUseKpiMatrixStatus).toBeCalledWith(mapping, data, ID, from, to, narrowDateRange);
});
});
afterAll(() => {
mockUseKpiMatrixStatus.mockRestore();
});
test(`it should apply correct mapping by given data type`, () => {
expect(mockUseKpiMatrixStatus).toBeCalledWith(mapping, data, ID, from, to, narrowDateRange);
});
}
);
});

View file

@ -96,7 +96,7 @@ describe('dateRanges', () => {
});
describe('#getDateRange', () => {
let dateSpy: jest.Mock<number, []>;
let dateSpy: jest.SpyInstance<number, []>;
beforeEach(() => {
dateSpy = jest

View file

@ -271,7 +271,9 @@ export const getMockPropsObj = ({
// silly that this needs to be an array and not an object
// https://jestjs.io/docs/en/api#testeachtable-name-fn-timeout
export const testCases = [
export const testCases: Array<
[LocationTypes, string, string, string, string | null, string, undefined | string]
> = [
[
/* page */ CONSTANTS.networkPage,
/* namespaceLower */ 'network',

View file

@ -8,12 +8,14 @@ import { isKpiHostDetailsQuery } from './helpers';
import { mockKpiHostsOptions, mockKpiHostDetailsOptions } from './mock';
describe('helpers', () => {
describe.each([[mockKpiHostsOptions, false], [mockKpiHostDetailsOptions, true]])(
'isHostDetails',
(option, expected) => {
test(`it should tell if it is kpiHostDetails option`, () => {
expect(isKpiHostDetailsQuery(option)).toBe(expected);
});
}
);
const table: Array<[typeof mockKpiHostDetailsOptions, boolean]> = [
[mockKpiHostsOptions, false],
[mockKpiHostDetailsOptions, true],
];
describe.each(table)('isHostDetails', (option, expected) => {
test(`it should tell if it is kpiHostDetails option`, () => {
expect(isKpiHostDetailsQuery(option)).toBe(expected);
});
});
});

View file

@ -12,10 +12,18 @@ import {
} from './mock';
import { buildAuthQuery } from './query_authentication.dsl';
describe.each([
[mockKpiHostsOptions, mockKpiHostsAuthQuery],
[mockKpiHostDetailsOptions, mockKpiHostDetailsAuthQuery],
])('buildAuthQuery', (option, expected) => {
const table = [
[mockKpiHostsOptions, mockKpiHostsAuthQuery] as [
typeof mockKpiHostsOptions,
typeof mockKpiHostsAuthQuery
],
[mockKpiHostDetailsOptions, mockKpiHostDetailsAuthQuery] as [
typeof mockKpiHostDetailsOptions,
typeof mockKpiHostDetailsAuthQuery
],
];
describe.each(table)('buildAuthQuery', (option, expected) => {
test(`returns correct query by option type`, () => {
expect(buildAuthQuery(option)).toMatchObject(expected);
});

View file

@ -12,10 +12,12 @@ import {
} from './mock';
import { buildUniqueIpsQuery } from './query_unique_ips.dsl';
describe.each([
const table: Array<[typeof mockKpiHostDetailsOptions, typeof mockKpiHostDetailsUniqueIpsQuery]> = [
[mockKpiHostsOptions, mockKpiHostsUniqueIpsQuery],
[mockKpiHostDetailsOptions, mockKpiHostDetailsUniqueIpsQuery],
])('buildUniqueIpsQuery', (option, expected) => {
];
describe.each(table)('buildUniqueIpsQuery', (option, expected) => {
test(`returns correct query by option type`, () => {
expect(buildUniqueIpsQuery(option)).toMatchObject(expected);
});

View file

@ -61,7 +61,7 @@
"@types/graphql": "^0.13.1",
"@types/hapi__wreck": "^15.0.1",
"@types/history": "^4.7.3",
"@types/jest": "^24.0.9",
"@types/jest": "^24.0.18",
"@types/joi": "^13.4.2",
"@types/js-yaml": "^3.11.1",
"@types/jsdom": "^12.2.4",
@ -138,9 +138,9 @@
"gulp-mocha": "2.2.0",
"gulp-multi-process": "1.3.1",
"hapi": "^17.5.3",
"jest": "^24.8.0",
"jest-cli": "^24.8.0",
"jest-styled-components": "^6.2.2",
"jest": "^24.9.0",
"jest-cli": "^24.9.0",
"jest-styled-components": "^6.3.3",
"jsdom": "^12.0.0",
"madge": "3.4.4",
"mocha": "3.5.3",

686
yarn.lock

File diff suppressed because it is too large Load diff