Skip to content

Commit 8e3203f

Browse files
committed
fix test
1 parent 3a9a556 commit 8e3203f

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

x-pack/plugins/lens/public/xy_visualization/visualization.test.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -560,24 +560,27 @@ describe('xy_visualization', () => {
560560
});
561561

562562
it('should respect the order of accessors coming from datasource', () => {
563-
const colorAssignment = require('./color_assignment'); // eslint-disable-line @typescript-eslint/no-var-requires
564-
const getAccessorColorConfigSpy = jest.spyOn(colorAssignment, 'getAccessorColorConfig');
565563
mockDatasource.publicAPIMock.getTableSpec.mockReturnValue([
566564
{ columnId: 'c' },
567565
{ columnId: 'b' },
568566
]);
569-
callConfigForYConfigs({});
570-
expect(getAccessorColorConfigSpy).toHaveBeenCalledWith(
571-
expect.anything(),
572-
expect.anything(),
573-
{
574-
accessors: ['c', 'b'],
575-
layerId: 'first',
576-
seriesType: 'area',
577-
xAccessor: 'a',
578-
},
579-
expect.anything()
580-
);
567+
const paletteGetter = jest.spyOn(paletteServiceMock, 'get');
568+
// overrite palette with a palette returning first blue, then green as color
569+
paletteGetter.mockReturnValue({
570+
id: 'default',
571+
title: '',
572+
getColors: jest.fn(),
573+
toExpression: jest.fn(),
574+
getColor: jest.fn().mockReturnValueOnce('blue').mockReturnValueOnce('green'),
575+
});
576+
577+
const yConfigs = callConfigForYConfigs({});
578+
expect(yConfigs?.accessors[0].columnId).toEqual('c');
579+
expect(yConfigs?.accessors[0].color).toEqual('blue');
580+
expect(yConfigs?.accessors[1].columnId).toEqual('b');
581+
expect(yConfigs?.accessors[1].color).toEqual('green');
582+
583+
paletteGetter.mockClear();
581584
});
582585
});
583586
});

0 commit comments

Comments
 (0)