|
8 | 8 | addTransform, |
9 | 9 | enhanceStyle, |
10 | 10 | generateSchemeList, |
| 11 | + getColorRange, |
11 | 12 | } from './heatmap_chart_utils'; |
12 | 13 | import { AggregationType, VisFieldType, ColorSchemas, ScaleType, VisColumn } from '../types'; |
13 | 14 | import { DEFAULT_GREY } from '../theme/default_colors'; |
@@ -356,3 +357,50 @@ describe('generateSchemeList', () => { |
356 | 357 | expect(result[7]).toBe('#585858'); |
357 | 358 | }); |
358 | 359 | }); |
| 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