mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
534cd1efa7
Per-framework fixes to pass D5 e2e-deep probes: - agno: deduplicate agent_server routes - claude-sdk-python: handle ParsedContentBlockStopEvent (SDK v0.97+) - claude-sdk-typescript: remove orphan tool-rendering page - crewai-crews: add backend tool_rendering agent + shared_state fix - google-adk: add AGUIToolset to all ADK agents for frontend tools - langgraph-typescript: remove stale import - langroid: emit ToolCallResultEvent for backend tools + fix adapter - llamaindex: v2 provider import, book_call stub, PYTHONPATH fix - ms-agent-python: disable Responses API store for aimock compat - pydantic-ai: simplify gen-ui page component - spring-ai: raise tool iteration cap (1→5) + fix connection pooling - strands: shared tools symlink + requirements update
80 lines
2.4 KiB
TypeScript
80 lines
2.4 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { getWeatherImpl } from "../get-weather";
|
|
|
|
describe("getWeatherImpl", () => {
|
|
it("returns all required fields", () => {
|
|
const result = getWeatherImpl("Tokyo");
|
|
expect(result).toHaveProperty("city");
|
|
expect(result).toHaveProperty("temperature");
|
|
expect(result).toHaveProperty("humidity");
|
|
expect(result).toHaveProperty("wind_speed");
|
|
expect(result).toHaveProperty("feels_like");
|
|
expect(result).toHaveProperty("conditions");
|
|
});
|
|
|
|
it("passes city name through", () => {
|
|
expect(getWeatherImpl("San Francisco").city).toBe("San Francisco");
|
|
});
|
|
|
|
it("is deterministic for the same city", () => {
|
|
const r1 = getWeatherImpl("Tokyo");
|
|
const r2 = getWeatherImpl("Tokyo");
|
|
expect(r1.temperature).toBe(r2.temperature);
|
|
expect(r1.conditions).toBe(r2.conditions);
|
|
});
|
|
|
|
it("produces different results for different cities", () => {
|
|
const r1 = getWeatherImpl("Tokyo");
|
|
const r2 = getWeatherImpl("London");
|
|
expect(r1).not.toEqual(r2);
|
|
});
|
|
|
|
it("temperature is within expected range (20-95)", () => {
|
|
const result = getWeatherImpl("Berlin");
|
|
expect(result.temperature).toBeGreaterThanOrEqual(20);
|
|
expect(result.temperature).toBeLessThanOrEqual(95);
|
|
});
|
|
|
|
it("humidity is within expected range (30-90)", () => {
|
|
const result = getWeatherImpl("Paris");
|
|
expect(result.humidity).toBeGreaterThanOrEqual(30);
|
|
expect(result.humidity).toBeLessThanOrEqual(90);
|
|
});
|
|
|
|
it("wind_speed is within expected range (2-30)", () => {
|
|
const result = getWeatherImpl("Sydney");
|
|
expect(result.wind_speed).toBeGreaterThanOrEqual(2);
|
|
expect(result.wind_speed).toBeLessThanOrEqual(30);
|
|
});
|
|
|
|
it("conditions is one of the known values", () => {
|
|
const known = [
|
|
"Sunny",
|
|
"Partly Cloudy",
|
|
"Cloudy",
|
|
"Overcast",
|
|
"Light Rain",
|
|
"Heavy Rain",
|
|
"Thunderstorm",
|
|
"Snow",
|
|
"Foggy",
|
|
"Windy",
|
|
];
|
|
const result = getWeatherImpl("Miami");
|
|
expect(known).toContain(result.conditions);
|
|
});
|
|
|
|
it("is case-insensitive for seed (lowercased internally)", () => {
|
|
const r1 = getWeatherImpl("tokyo");
|
|
const r2 = getWeatherImpl("TOKYO");
|
|
expect(r1.temperature).toBe(r2.temperature);
|
|
});
|
|
|
|
it("feels_like is within ±5 of temperature", () => {
|
|
const result = getWeatherImpl("Berlin");
|
|
expect(
|
|
Math.abs(result.feels_like - result.temperature),
|
|
).toBeLessThanOrEqual(5);
|
|
});
|
|
});
|