[Lens] mock htmlIDGenerator to avoid messages when running tests (#101042) (#101066)

Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>
This commit is contained in:
Kibana Machine 2021-06-01 13:54:54 -04:00 committed by GitHub
parent ff6a5a856d
commit 4b9c159e57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View file

@ -11,6 +11,19 @@ import React from 'react';
import { act } from 'react-dom/test-utils';
import { CustomStops, CustomStopsProps } from './color_stops';
// mocking random id generator function
jest.mock('@elastic/eui', () => {
const original = jest.requireActual('@elastic/eui');
return {
...original,
htmlIdGenerator: (fn: unknown) => {
let counter = 0;
return () => counter++;
},
};
});
describe('Color Stops component', () => {
let props: CustomStopsProps;
beforeEach(() => {

View file

@ -15,6 +15,19 @@ import { CustomPaletteParams } from './types';
import { applyPaletteParams } from './utils';
import { CustomizablePalette } from './palette_configuration';
// mocking random id generator function
jest.mock('@elastic/eui', () => {
const original = jest.requireActual('@elastic/eui');
return {
...original,
htmlIdGenerator: (fn: unknown) => {
let counter = 0;
return () => counter++;
},
};
});
describe('palette utilities', () => {
const paletteRegistry = chartPluginMock.createPaletteRegistry();
describe('applyPaletteParams', () => {