import {createLatestBandIndices} from './band' import {DomainLabel} from '../../types' describe('createLatestBandIndices', () => { const lineData = { 0: { fill: 'rgb(49, 192, 246)', xs: [ 1596664920000, 1596664980000, 1596665040000, 1596665100000, 1596665160000, 1596665196906, ], ys: [12.8, 18.581418581418582, 14.1, 13.8, 14.7, 12.9], }, 1: { fill: 'rgb(195, 52, 148)', xs: [ 1596664920000, 1596664980000, 1596665040000, 1596665100000, 1596665160000, 1596665196906, ], ys: [ 1.2987012987012987, 2.6, 1.5, 1.6016016016016017, 1.8, 1.3013013013013013, ], }, 2: { fill: 'rgb(49, 192, 246)', xs: [ 1596664920000, 1596664980000, 1596665040000, 1596665100000, 1596665160000, 1596665196906, ], ys: [ 12.587412587412587, 13.1, 12.5, 12.687312687312687, 11.7, 12.087912087912088, ], }, 3: { fill: 'rgb(195, 52, 148)', xs: [ 1596664920000, 1596664980000, 1596665040000, 1596665100000, 1596665160000, 1596665196906, ], ys: [1.1011011011011012, 1.3, 1.2, 1.098901098901099, 1, 1.2], }, 4: { fill: 'rgb(49, 192, 246)', xs: [ 1596664920000, 1596664980000, 1596665040000, 1596665100000, 1596665160000, 1596665196906, ], ys: [ 12.693706293706294, 14.432488682488682, 13.318985652318984, 13.214552114552115, 12.968918918918918, 12.42930402930403, ], }, 5: { fill: 'rgb(195, 52, 148)', xs: [ 1596664920000, 1596664980000, 1596665040000, 1596665100000, 1596665160000, 1596665196906, ], ys: [ 1.1999011999012, 1.6000005000005002, 1.3499342332675666, 1.333500900167567, 1.3332675332675332, 1.2666675333342, ], }, } const bandLineMap = { upperLines: [0, 1], rowLines: [4, 5], lowerLines: [2, 3], } it('creates the latest band indices for the static legend', () => { expect( createLatestBandIndices(lineData, bandLineMap, DomainLabel.X) ).toEqual({0: 5, 1: 11, 2: 17, 3: 23, 4: 29, 5: 35}) }) it('creates the band indices for the tooltip', () => { expect( createLatestBandIndices(lineData, bandLineMap, DomainLabel.X, { 4: 26, 5: 32, }) ).toEqual({0: 2, 1: 8, 2: 14, 3: 20, 4: 26, 5: 32}) }) })