Skip to content

Commit 7ba13cd

Browse files
committed
add tests
Signed-off-by: Qxisylolo <[email protected]>
1 parent 8400725 commit 7ba13cd

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/plugins/explore/public/components/visualizations/heatmap/heatmap_chart_utils.test.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
addTransform,
99
enhanceStyle,
1010
generateSchemeList,
11+
getColorRange,
1112
} from './heatmap_chart_utils';
1213
import { AggregationType, VisFieldType, ColorSchemas, ScaleType, VisColumn } from '../types';
1314
import { DEFAULT_GREY } from '../theme/default_colors';
@@ -356,3 +357,50 @@ describe('generateSchemeList', () => {
356357
expect(result[7]).toBe('#585858');
357358
});
358359
});
360+
361+
describe('getColorRange', () => {
362+
beforeEach(() => {
363+
jest.clearAllMocks();
364+
});
365+
366+
it('should return blues color scheme', () => {
367+
const result = getColorRange(ColorSchemas.BLUES);
368+
expect(result).toHaveLength(11);
369+
expect(result[5]).toBe('#6092c0');
370+
});
371+
372+
it('should return purples color scheme', () => {
373+
const result = getColorRange(ColorSchemas.PURPLES);
374+
expect(result).toHaveLength(11);
375+
expect(result[5]).toBe('#9170b8');
376+
});
377+
378+
it('should return oranges color scheme', () => {
379+
const result = getColorRange(ColorSchemas.ORANGES);
380+
expect(result).toHaveLength(11);
381+
expect(result[5]).toBe('#e7664c');
382+
});
383+
384+
it('should return yellows color scheme', () => {
385+
const result = getColorRange(ColorSchemas.YELLOWS);
386+
expect(result).toHaveLength(11);
387+
expect(result[5]).toBe('#d6bf57');
388+
});
389+
390+
it('should return greens color scheme', () => {
391+
const result = getColorRange(ColorSchemas.GREENS);
392+
expect(result).toHaveLength(11);
393+
expect(result[5]).toBe('#54b399');
394+
});
395+
396+
it('should return reds color scheme', () => {
397+
const result = getColorRange(ColorSchemas.REDS);
398+
expect(result).toHaveLength(11);
399+
expect(result[5]).toBe('#d36086');
400+
});
401+
402+
it('should return undefined for unknown color schema', () => {
403+
const result = getColorRange('UNKNOWN' as ColorSchemas);
404+
expect(result).toBeUndefined();
405+
});
406+
});

0 commit comments

Comments
 (0)