import { describe, it, expect } from 'vitest' import { render } from '@testing-library/react' import { Series } from './series' import { Value } from './value' import { Note } from './note' import { Prefix } from './prefix' import { Suffix } from './suffix' import { Delta } from './delta' describe('', () => { it('renders the first letter of name as an Avatar', () => { const { getByLabelText } = render() const av = getByLabelText('Revenue') expect(av.textContent).toBe('R') }) it('honours a custom size', () => { const { getByLabelText } = render() expect(getByLabelText('Cogs')).toBeTruthy() }) it('passes a CSS colour through unchanged', () => { const { getByLabelText } = render() expect(getByLabelText('X')).toBeTruthy() }) it('resolves a dotted palette path to a concrete colour via the theme', () => { const { getByLabelText } = render() expect(getByLabelText('Y')).toBeTruthy() }) it('resolves a nested palette path (palette.warning.dark)', () => { const { getByLabelText } = render() expect(getByLabelText('W')).toBeTruthy() }) }) describe('', () => { it('renders children', () => { const { getByText } = render(42) expect(getByText('42')).toBeTruthy() }) it('applies the supplied color override', () => { const { getByText } = render(ok) expect(getByText('ok')).toBeTruthy() }) }) describe('', () => { it('renders children', () => { const { getByText } = render(last 7 days) expect(getByText('last 7 days')).toBeTruthy() }) }) describe('', () => { it('renders children', () => { const { getByText } = render($) expect(getByText('$')).toBeTruthy() }) }) describe('', () => { it('renders children', () => { const { getByText } = render(%) expect(getByText('%')).toBeTruthy() }) }) describe('', () => { it('infers positive severity from a positive value', () => { const { container } = render() // Default percent formatter with signDisplay='always'. expect(container.textContent).toContain('+12%') expect(container.querySelector('.MuiChip-colorSuccess')).not.toBeNull() }) it('infers negative severity from a negative value', () => { const { container } = render() expect(container.textContent).toContain('-5%') expect(container.querySelector('.MuiChip-colorError')).not.toBeNull() }) it('infers neutral severity from zero', () => { const { container } = render() expect(container.textContent).toContain('+0%') expect(container.querySelector('.MuiChip-colorDefault')).not.toBeNull() }) it('renders an explicit label, bypassing the formatter', () => { const { getByText } = render() expect(getByText('down a lot')).toBeTruthy() }) it('uses a custom format() when provided', () => { const { container } = render( `${v.toFixed(2)}x`} />, ) expect(container.textContent).toContain('3.14x') }) it('honours an explicit severity override', () => { const { container } = render() expect(container.querySelector('.MuiChip-colorDefault')).not.toBeNull() }) })