Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
- Move Dawnline to Services in LuCI and update links and documentation. - Make activity messages clearer, including device renames and person-specific history. - Prune redundant frontend tests.
31 lines
944 B
TypeScript
31 lines
944 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import type { Pair } from '../src/shared/types';
|
|
import { mirror, sumDays } from '../src/portal/ui/bars';
|
|
|
|
/** [rx, tx]: what the device sent, what it received. */
|
|
const days: Pair[] = [
|
|
[10, 90],
|
|
[40, 60],
|
|
[5, 120],
|
|
];
|
|
|
|
describe('mirrored bars', () => {
|
|
it('fits both peaks on one scale, the tighter one filling its half', () => {
|
|
const m = mirror(days, 64);
|
|
expect(120 * m.scale).toBeLessThanOrEqual(m.top);
|
|
expect(40 * m.scale).toBeLessThanOrEqual(m.bottom);
|
|
expect(Math.max(120 * m.scale - m.top, 40 * m.scale - m.bottom)).toBeCloseTo(0);
|
|
});
|
|
|
|
it('draws a month without traffic', () => {
|
|
const m = mirror([[0, 0]], 34);
|
|
expect(Number.isFinite(m.scale)).toBe(true);
|
|
expect(m.top).toBeGreaterThan(m.bottom);
|
|
});
|
|
|
|
it('adds the days up both ways', () => {
|
|
expect(sumDays(days)).toEqual([55, 270]);
|
|
expect(sumDays([])).toEqual([0, 0]);
|
|
});
|
|
});
|