Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

806 B
Raw Blame
import { describe, expect, it } from 'vitest';

import { donutLegendCategories, showsDonutTotal } from './donut';

describe('showsDonutTotal', () => {
  it('hides the center total for shares of a whole', () => {
    expect(showsDonutTotal({ unit: '%' })).toBe(false);
    expect(showsDonutTotal({ 'value-format': 'percent' })).toBe(false);
    expect(showsDonutTotal({ unit: 'ε…ƒ' })).toBe(true);
  });
});

describe('donutLegendCategories', () => {
  it('names every slice in data order', () => {
    const rows = [
      { region: '华东', share: 45 },
      { region: 'εŽε—', share: 30 },
      { region: 'εŽεŒ—', share: 25 },
    ];
    expect(donutLegendCategories(rows, 'region')).toEqual(['华东', 'εŽε—', 'εŽεŒ—']);
    expect(donutLegendCategories(rows, undefined)).toEqual([]);
  });
});