import { describe, it, expect } from 'vitest';
import * as glyphs from '../glyphs';
import {
  GLYPH_REVEAL, GLYPH_HIDE, GLYPH_GENERATE, GLYPH_FILL_FROM_TAB,
  GLYPH_QR, GLYPH_MONO, GLYPH_TRASH, GLYPH_DEVICES, GLYPH_SETTINGS,
  GLYPH_LOCK, GLYPH_NEXT,
} from '../glyphs';

describe('glyphs', () => {
  it('exports the documented glyph constants', () => {
    expect(glyphs.GLYPH_REVEAL).toBe('⊙');
    expect(glyphs.GLYPH_HIDE).toBe('⊘');
    expect(glyphs.GLYPH_GENERATE).toBe('↻');
    expect(glyphs.GLYPH_FILL_FROM_TAB).toBe('⤓');
    expect(glyphs.GLYPH_QR).toBe('◫');
    expect(glyphs.GLYPH_MONO).toBe('≡');
    expect(glyphs.GLYPH_TRASH).toBe('▦');
    expect(glyphs.GLYPH_DEVICES).toBe('⌬');
    expect(glyphs.GLYPH_SETTINGS).toBe('⚙');
    expect(glyphs.GLYPH_LOCK).toBe('⏻');
  });

  it('exports REQUIRED_PILL_HTML as an HTML snippet', () => {
    expect(glyphs.REQUIRED_PILL_HTML).toBe('<span class="req-pill">required</span>');
  });
});

describe('glyph constants', () => {
  it('uses single unicode codepoints (no emoji multi-codepoint)', () => {
    const all = [
      GLYPH_REVEAL, GLYPH_HIDE, GLYPH_GENERATE, GLYPH_FILL_FROM_TAB,
      GLYPH_QR, GLYPH_MONO, GLYPH_TRASH, GLYPH_DEVICES, GLYPH_SETTINGS,
      GLYPH_LOCK, GLYPH_NEXT,
    ];
    for (const g of all) {
      expect([...g].length).toBe(1);
    }
  });

  it('GLYPH_NEXT is the small right triangle (U+25B8)', () => {
    expect(GLYPH_NEXT).toBe('▸');
  });
});

describe('Stream A glyphs (vault tab + type icons)', () => {
  it('exports GLYPH_VAULT_TAB as U+29C9', () => {
    expect(glyphs.GLYPH_VAULT_TAB).toBe('⧉');
  });

  it('exports per-type glyph constants', () => {
    expect(glyphs.GLYPH_TYPE_LOGIN).toBe('◉');
    expect(glyphs.GLYPH_TYPE_SECURE_NOTE).toBe('◫');
    expect(glyphs.GLYPH_TYPE_TOTP).toBe('⊡');
    expect(glyphs.GLYPH_TYPE_CARD).toBe('▭');
    expect(glyphs.GLYPH_TYPE_IDENTITY).toBe('◍');
    expect(glyphs.GLYPH_TYPE_KEY).toBe('⊹');
    expect(glyphs.GLYPH_TYPE_DOCUMENT).toBe('≡');
  });

  it('per-type glyphs are single codepoints (no emoji)', () => {
    const typeGlyphs = [
      glyphs.GLYPH_TYPE_LOGIN, glyphs.GLYPH_TYPE_SECURE_NOTE, glyphs.GLYPH_TYPE_TOTP,
      glyphs.GLYPH_TYPE_CARD, glyphs.GLYPH_TYPE_IDENTITY, glyphs.GLYPH_TYPE_KEY,
      glyphs.GLYPH_TYPE_DOCUMENT,
    ];
    for (const g of typeGlyphs) {
      expect([...g].length).toBe(1);
    }
  });
});

describe('management-surface glyphs', () => {
  it('exposes a history glyph', () => {
    expect(glyphs.GLYPH_HISTORY).toBe('◷');
  });

  it('exposes a revoke glyph distinct from reveal/hide semantics', () => {
    expect(glyphs.GLYPH_REVOKE).toBe('⊘');
  });

  it('exposes a restore glyph for trash actions', () => {
    expect(glyphs.GLYPH_RESTORE).toBe('⤺');
  });
});
