import { rankHybridEntries } from '../../utils/hybridSearch';

describe('semantic category matrix', () => {
  const entries = [
    { name: 'Starter Plant', botanicalName: 'Starter easya', description: 'Hard to kill starter plant.', categories: ['easy'], careInfo: { waterIntervalDays: 7, light: 'Bright indirect light', temp: '18-24C' } },
    { name: 'Office Shade Plant', botanicalName: 'Shadea officis', description: 'Handles office corners well.', categories: ['low_light'], careInfo: { waterIntervalDays: 8, light: 'Low light', temp: '18-24C' } },
    { name: 'Bright Window Plant', botanicalName: 'Brighta windowii', description: 'Thrives in bright rooms.', categories: ['bright_light'], careInfo: { waterIntervalDays: 7, light: 'Bright indirect light', temp: '18-24C' } },
    { name: 'Sunny Aloe', botanicalName: 'Aloe vera', description: 'Sun-loving succulent for a south-facing window.', categories: ['sun'], careInfo: { waterIntervalDays: 12, light: 'Sunny', temp: '18-30C' } },
    { name: 'Safe Pilea', botanicalName: 'Pilea peperomioides', description: 'Non toxic and pet friendly.', categories: ['pet_friendly'], careInfo: { waterIntervalDays: 7, light: 'Bright indirect light', temp: '18-24C' } },
    { name: 'Air Cleaner Plant', botanicalName: 'Chlorophytum comosum', description: 'Helps clean the air indoors.', categories: ['air_purifier'], careInfo: { waterIntervalDays: 6, light: 'Bright to partial shade', temp: '16-24C' } },
    { name: 'Bathroom Fern', botanicalName: 'Nephrolepis exaltata', description: 'Loves humidity and steady moisture.', categories: ['high_humidity'], careInfo: { waterIntervalDays: 3, light: 'Partial shade', temp: '16-24C' } },
    { name: 'Trailing Vine', botanicalName: 'Epipremnum aureum', description: 'Fast-growing trailing shelf plant.', categories: ['hanging'], careInfo: { waterIntervalDays: 7, light: 'Partial shade to bright', temp: '18-27C' } },
    { name: 'Striped Leaf Plant', botanicalName: 'Calathea ornata', description: 'Decorative leaves with striped patterns.', categories: ['patterned'], careInfo: { waterIntervalDays: 5, light: 'Partial shade', temp: '18-25C' } },
    { name: 'Bloom Plant', botanicalName: 'Spathiphyllum', description: 'Reliable flowering houseplant.', categories: ['flowering'], careInfo: { waterIntervalDays: 5, light: 'Partial shade', temp: '18-26C' } },
    { name: 'Desert Succulent', botanicalName: 'Echeveria elegans', description: 'Classic cactus-like drought tolerant succulent.', categories: ['succulent'], careInfo: { waterIntervalDays: 14, light: 'Sunny', temp: '15-25C' } },
    { name: 'Indoor Tree', botanicalName: 'Ficus lyrata', description: 'Beautiful floor tree for bright rooms.', categories: ['tree'], careInfo: { waterIntervalDays: 7, light: 'Bright light', temp: '18-26C' } },
    { name: 'Statement Plant', botanicalName: 'Strelitzia nicolai', description: 'Tall oversized statement plant.', categories: ['large'], careInfo: { waterIntervalDays: 7, light: 'Bright light', temp: '18-27C' } },
    { name: 'Healing Herb', botanicalName: 'Mentha spicata', description: 'Kitchen herb and medicinal tea herb.', categories: ['medicinal'], careInfo: { waterIntervalDays: 3, light: 'Bright light', temp: '15-25C' } },
  ];

  const cases: Array<[string, string]> = [
    ['hard to kill plant', 'Starter Plant'],
    ['office plant for dark corner', 'Office Shade Plant'],
    ['plant for east window', 'Bright Window Plant'],
    ['plant for sunny window', 'Sunny Aloe'],
    ['non toxic plant for cats', 'Safe Pilea'],
    ['cleaner air plant', 'Air Cleaner Plant'],
    ['bathroom plant', 'Bathroom Fern'],
    ['trailing shelf plant', 'Trailing Vine'],
    ['striped decorative leaves', 'Striped Leaf Plant'],
    ['plant with blooms', 'Bloom Plant'],
    ['cactus-like plant', 'Desert Succulent'],
    ['indoor tree', 'Indoor Tree'],
    ['tall statement plant', 'Statement Plant'],
    ['kitchen tea herb', 'Healing Herb'],
  ];

  it.each(cases)('maps "%s" to %s', (query, expectedName) => {
    const results = rankHybridEntries(entries, query, 5);
    expect(results[0].entry.name).toBe(expectedName);
  });
});
