Improvements to the polygon spatial viz (#6178)

* WIP

* WIP

* WIP

* WIP

* Fix color bucketing

* Fixed colors

* Fix no num categories selected

* Colors working

* Fix no metric selected

* Visual cues for selection

* Add unit tests

* Remove jest from deps

* Rename category to bucket

* Small fixes

* Fix lint

* Fix unit tests

* Remove duplicate hexToRGB

* Fix import

* Change order of arguments in getBuckets

* Refactor function signature
This commit is contained in:
Beto Dealmeida
2018-10-24 18:40:57 -07:00
committed by GitHub
parent ca5be1c1e2
commit f1089c40a4
17 changed files with 2372 additions and 42 deletions

View File

@@ -1,12 +1,29 @@
import { hexToRGB } from '../../../src/modules/colors';
describe('colors', () => {
describe('hexToRGB', () => {
it('is a function', () => {
expect(typeof hexToRGB).toBe('function');
});
it('hexToRGB converts properly', () => {
expect(hexToRGB('#FFFFFF')).toEqual(expect.arrayContaining([255, 255, 255, 255]));
expect(hexToRGB('#000000')).toEqual(expect.arrayContaining([0, 0, 0, 255]));
expect(hexToRGB('#FF0000')).toEqual(expect.arrayContaining([255, 0, 0, 255]));
expect(hexToRGB('#00FF00')).toEqual(expect.arrayContaining([0, 255, 0, 255]));
expect(hexToRGB('#0000FF')).toEqual(expect.arrayContaining([0, 0, 255, 255]));
});
it('works with falsy values', () => {
expect(hexToRGB()).toEqual([0, 0, 0, 255]);
/* eslint-disable quotes */
[false, 0, -0, 0.0, '', "", ``, null, undefined, NaN].forEach((value) => {
expect(hexToRGB(value)).toEqual(expect.arrayContaining([0, 0, 0, 255]));
});
});
it('takes and alpha argument', () => {
expect(hexToRGB('#FF0000', 128)).toEqual(expect.arrayContaining([255, 0, 0, 128]));
expect(hexToRGB('#000000', 100)).toEqual(expect.arrayContaining([0, 0, 0, 100]));
expect(hexToRGB('#ffffff', 0)).toEqual(expect.arrayContaining([255, 255, 255, 0]));
});
});