-
Notifications
You must be signed in to change notification settings - Fork 592
/
bin.test.ts
39 lines (36 loc) · 1.05 KB
/
bin.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import {autoMaxBins, binToString, isBinParams} from '../src/bin';
import {
COLOR,
COLUMN,
FILL,
FILLOPACITY,
OPACITY,
ROW,
SHAPE,
SIZE,
STROKE,
STROKEOPACITY,
STROKEWIDTH
} from '../src/channel';
describe('autoMaxBins', () => {
it('should assign generate correct defaults for different channels', () => {
// Not testing case for 10 because it's already tested
[COLOR, FILL, STROKE, STROKEWIDTH, SIZE, OPACITY, FILLOPACITY, STROKEOPACITY, SHAPE, ROW, COLUMN].forEach(a =>
expect(autoMaxBins(a)).toEqual(6)
);
});
});
describe('binToString', () => {
it('should generate the correct key for boolean', () => {
expect(binToString(true)).toBe('bin_maxbins_10');
});
});
describe('isBinParams', () => {
it('should detect whether the input is BinParams or not', () => {
expect(isBinParams(true)).toEqual(false);
expect(isBinParams('binned')).toEqual(false);
expect(isBinParams({})).toEqual(true);
expect(isBinParams({binned: true})).toEqual(true);
expect(isBinParams({extent: [0, 1]})).toEqual(true);
});
});