Files
snapcad-studio/tests/unit/solarSystem.test.ts
T

51 lines
1.8 KiB
TypeScript
Raw Normal View History

import { describe, it, expect } from "vitest";
import {
calculateSunPosition,
DEFAULT_SOLAR_SETTINGS,
SOLAR_LOCATIONS,
type SolarStudySettings,
} from "@/lib/solarSystem";
describe("Solar Study & Sun Position System (Mimari Güneş & Gölge Etüdü)", () => {
it("provides architectural location presets including Istanbul and Ankara", () => {
expect(SOLAR_LOCATIONS.length).toBeGreaterThanOrEqual(5);
const names = SOLAR_LOCATIONS.map((l) => l.name);
expect(names.some((n) => n.includes("İstanbul"))).toBe(true);
expect(names.some((n) => n.includes("Ankara"))).toBe(true);
});
it("calculates peak sun altitude at noon in June", () => {
const noonSummer: SolarStudySettings = {
...DEFAULT_SOLAR_SETTINGS,
hour: 12.0,
month: 5, // June
day: 21,
};
const pos = calculateSunPosition(noonSummer);
expect(pos.isDaylight).toBe(true);
expect(pos.altitudeDegrees).toBeGreaterThan(60); // In Istanbul, summer solstice noon is ~72 deg
expect(pos.lightVector[1]).toBeGreaterThan(150); // High Y position
});
it("calculates lower sun altitude and longer shadows in winter solstice (December)", () => {
const noonWinter: SolarStudySettings = {
...DEFAULT_SOLAR_SETTINGS,
hour: 12.0,
month: 11, // December
day: 21,
};
const pos = calculateSunPosition(noonWinter);
expect(pos.altitudeDegrees).toBeLessThan(35); // Winter noon in Istanbul is ~25-26 deg
});
it("produces warm golden hour lighting colors near sunrise/sunset", () => {
const sunsetSettings: SolarStudySettings = {
...DEFAULT_SOLAR_SETTINGS,
hour: 20.2, // Around sunset in summer in Istanbul
month: 5,
day: 21,
};
const pos = calculateSunPosition(sunsetSettings);
expect(pos.lightColorHex).toMatch(/^#(ffaa44|ffe4b5|fffcf2)$/);
});
});