import { describe, it, expect } from 'vitest';
import { siteData } from '../data/siteData';

describe('siteData', () => {
  it('has brand data with name and slogan', () => {
    expect(siteData.brand).toBeDefined();
    expect(siteData.brand.name).toHaveProperty('zh');
    expect(siteData.brand.name).toHaveProperty('en');
    expect(siteData.brand.slogan).toHaveProperty('zh');
  });

  it('has nav items', () => {
    expect(siteData.nav.length).toBeGreaterThan(0);
    expect(siteData.nav[0]).toHaveProperty('id');
    expect(siteData.nav[0]).toHaveProperty('label');
  });

  it('has categories', () => {
    expect(siteData.categories.length).toBeGreaterThan(0);
    expect(siteData.categories[0]).toHaveProperty('id');
    expect(siteData.categories[0]).toHaveProperty('label');
    expect(siteData.categories[0]).toHaveProperty('icon');
  });

  it('has statuses', () => {
    expect(Object.keys(siteData.statuses).length).toBeGreaterThan(0);
    const firstStatus = Object.values(siteData.statuses)[0];
    expect(firstStatus).toHaveProperty('label');
    expect(firstStatus).toHaveProperty('color');
  });

  it('has platforms', () => {
    expect(Object.keys(siteData.platforms).length).toBeGreaterThan(0);
  });

  it('has projects sorted by order', () => {
    expect(siteData.projects.length).toBeGreaterThan(0);
    for (let i = 1; i < siteData.projects.length; i++) {
      expect(siteData.projects[i].order).toBeGreaterThanOrEqual(
        siteData.projects[i - 1].order
      );
    }
  });

  it('each project has required fields', () => {
    for (const p of siteData.projects) {
      expect(p.id).toBeTruthy();
      expect(p.name).toBeTruthy();
      expect(p.displayName).toHaveProperty('zh');
      expect(p.displayName).toHaveProperty('en');
      expect(p.slogan).toHaveProperty('zh');
      expect(p.techStack).toBeInstanceOf(Array);
      expect(p.platforms).toBeInstanceOf(Array);
    }
  });

  it('has i18n data for zh and en', () => {
    expect(siteData.i18n.zh).toBeDefined();
    expect(siteData.i18n.en).toBeDefined();
    expect(Object.keys(siteData.i18n.zh).length).toBeGreaterThan(0);
    expect(Object.keys(siteData.i18n.en).length).toBeGreaterThan(0);
  });

  it('has about data', () => {
    expect(siteData.about).toBeDefined();
    expect(siteData.about.bio).toHaveProperty('zh');
    expect(siteData.about.bio).toHaveProperty('en');
  });
});
