Skip to content

Commit

Permalink
[Lens] mock htmlIDGenerator to avoid messages when running tests (#10…
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra authored Jun 1, 2021
1 parent 38fd8a2 commit 1f6e514
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 1f6e514

Please sign in to comment.