towerops/test/assets/chart_dataset_config_test.mjs

34 lines
991 B
JavaScript

import test from 'node:test'
import assert from 'node:assert/strict'
import { buildChartDatasets } from '../../assets/js/chart_dataset_config.mjs'
test('preserves explicit fill settings on traffic datasets', () => {
const datasets = buildChartDatasets(
{
datasets: [
{ label: 'Outbound', data: [{ x: 1, y: -100 }] },
{ label: 'Capacity (Out)', data: [{ x: 1, y: -300 }], fill: false, borderDash: [5, 5] }
]
},
{ isTrafficChart: true, dualAxis: false }
)
assert.equal(datasets[0].fill, 'origin')
assert.equal(datasets[1].fill, false)
assert.deepEqual(datasets[1].borderDash, [5, 5])
})
test('uses stepped fill for dual-axis status datasets', () => {
const datasets = buildChartDatasets(
{
datasets: [
{ label: 'Status', yAxisID: 'y1', data: [{ x: 1, y: 1 }] }
]
},
{ isTrafficChart: false, dualAxis: true }
)
assert.equal(datasets[0].stepped, 'before')
assert.equal(datasets[0].fill, 'origin')
})