import { describe, expect, it } from 'vitest';
import { GET } from './+server';

describe('sitemap endpoint', () => {
  it('returns a sitemap covering the published routes', async () => {
    const response = await GET({} as never);
    const body = await response.text();

    expect(response.headers.get('content-type')).toBe('application/xml; charset=utf-8');
    expect(body).toContain('<loc>https://www.goodwalk.co.nz/</loc>');
    expect(body).toContain('<loc>https://www.goodwalk.co.nz/contact-us</loc>');
    expect(body).toContain('<loc>https://www.goodwalk.co.nz/privacy-policy</loc>');
    expect(body).toContain('<lastmod>2026-05-12</lastmod>');
    expect(body).toContain('<loc>https://www.goodwalk.co.nz/locations/mt-eden</loc>');
    expect(body).toContain('<loc>https://www.goodwalk.co.nz/locations/kingsland</loc>');
    // 9 core pages + 17 location pages
    expect(body.match(/<url>/g)).toHaveLength(26);
  });
});
