'use strict';

// P2-9 — the canonical SHORT stat label. Raw snake_case ("stolen_bases U0.5")
// on the leaderboard was the display bug; lock the abbreviations the audit named.

const { statAbbrev, STAT_ABBREV } = require('../../web/src/lib/statAbbrev');

describe('statAbbrev', () => {
  test('the audit-named MLB stats map to short labels', () => {
    expect(statAbbrev('stolen_bases')).toBe('SB');
    expect(statAbbrev('earned_runs')).toBe('ER');
    expect(statAbbrev('total_bases')).toBe('TB');
    expect(statAbbrev('home_runs')).toBe('HR');
    expect(statAbbrev('strikeouts')).toBe('K');
  });

  test('NBA stats too', () => {
    expect(statAbbrev('points')).toBe('PTS');
    expect(statAbbrev('rebounds')).toBe('REB');
    expect(statAbbrev('assists')).toBe('AST');
  });

  test('an unknown id upper-cases its words (never leaks raw snake_case)', () => {
    expect(statAbbrev('some_new_stat')).toBe('SOME NEW STAT');
    expect(statAbbrev('some_new_stat')).not.toContain('_');
  });

  test('null / empty is safe', () => {
    expect(statAbbrev(null)).toBe('');
    expect(statAbbrev('')).toBe('');
  });

  test('no label contains an underscore (all are real abbreviations)', () => {
    for (const v of Object.values(STAT_ABBREV)) expect(v).not.toContain('_');
  });
});
