Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Dec 3, 2020
1 parent 3a9a556 commit 8e3203f
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions x-pack/plugins/lens/public/xy_visualization/visualization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,24 +560,27 @@ describe('xy_visualization', () => {
});

it('should respect the order of accessors coming from datasource', () => {
const colorAssignment = require('./color_assignment'); // eslint-disable-line @typescript-eslint/no-var-requires
const getAccessorColorConfigSpy = jest.spyOn(colorAssignment, 'getAccessorColorConfig');
mockDatasource.publicAPIMock.getTableSpec.mockReturnValue([
{ columnId: 'c' },
{ columnId: 'b' },
]);
callConfigForYConfigs({});
expect(getAccessorColorConfigSpy).toHaveBeenCalledWith(
expect.anything(),
expect.anything(),
{
accessors: ['c', 'b'],
layerId: 'first',
seriesType: 'area',
xAccessor: 'a',
},
expect.anything()
);
const paletteGetter = jest.spyOn(paletteServiceMock, 'get');
// overrite palette with a palette returning first blue, then green as color
paletteGetter.mockReturnValue({
id: 'default',
title: '',
getColors: jest.fn(),
toExpression: jest.fn(),
getColor: jest.fn().mockReturnValueOnce('blue').mockReturnValueOnce('green'),
});

const yConfigs = callConfigForYConfigs({});
expect(yConfigs?.accessors[0].columnId).toEqual('c');
expect(yConfigs?.accessors[0].color).toEqual('blue');
expect(yConfigs?.accessors[1].columnId).toEqual('b');
expect(yConfigs?.accessors[1].color).toEqual('green');

paletteGetter.mockClear();
});
});
});
Expand Down

0 comments on commit 8e3203f

Please sign in to comment.