import { describe, it, expect } from "vitest";
describe("search_products tool", () => {
it("返回匹配的商品", async () => {
const result = await searchProducts("跑步鞋", { limit: 5 });
expect(result.results).toHaveLength(5);
expect(result.results[0]).toHaveProperty("name");
expect(result.results[0]).toHaveProperty("price");
});
it("空搜索返回空数组", async () => {
const result = await searchProducts("不存在的商品xyz", { limit: 5 });
expect(result.results).toHaveLength(0);
});
it("价格范围筛选有效", async () => {
const result = await searchProducts("鞋", {
minPrice: 500,
maxPrice: 1000,
limit: 10
});
result.results.forEach(p => {
expect(p.price).toBeGreaterThanOrEqual(500);
expect(p.price).toBeLessThanOrEqual(1000);
});
});
});