chore(publish): replace source tree with static export at repo root
Publish the prerendered static export (index.html, 404.html, cinema/,
c/, about/, for-cinemas/, for-film-lovers/, assets/, images/, og/,
sitemap.xml, robots.txt) as the site root and remove the React Router
+ Nitro source tree from this branch. Source remains available in
history at 0548772.
Note: public/sw.js here reports VERSION v2.0.5 while the removed source
tree (v2.1.0) was newer, and .gitignore was not carried over.
This commit is contained in:
1 parent
05487728a7
commit
e6c4ebff48
394 files changed
+3977
-37891
No files matched your search
@@ -1,96 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
formatDistance,
|
||||
haversineKm,
|
||||
parseOsrmTable,
|
||||
sortByDistance,
|
||||
straightLineDistance,
|
||||
type DistanceResult,
|
||||
} from "./geo";
|
||||
|
||||
const SAMYAN = { latitude: 13.7343452, longitude: 100.5282654 };
|
||||
const NGAMWONGWAN = { latitude: 13.8564363, longitude: 100.5419053 };
|
||||
|
||||
describe("haversineKm", () => {
|
||||
it("ระยะทางเส้นตรง Samyan → งามวงศ์วาน ประมาณ 13.6 กม.", () => {
|
||||
const km = haversineKm(SAMYAN, NGAMWONGWAN);
|
||||
expect(km).toBeGreaterThan(13);
|
||||
expect(km).toBeLessThan(14.5);
|
||||
});
|
||||
|
||||
it("จุดเดียวกันได้ 0", () => {
|
||||
expect(haversineKm(SAMYAN, SAMYAN)).toBeCloseTo(0, 5);
|
||||
});
|
||||
});
|
||||
|
||||
describe("straightLineDistance", () => {
|
||||
it("ติดป้ายว่าเป็นค่าประมาณ (เส้นตรง × detour factor)", () => {
|
||||
const result = straightLineDistance(SAMYAN, NGAMWONGWAN);
|
||||
expect(result.source).toBe("straight");
|
||||
expect(result.distance_km).toBeGreaterThan(haversineKm(SAMYAN, NGAMWONGWAN));
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseOsrmTable", () => {
|
||||
it("ข้ามคอลัมน์แรก (ต้นทาง) และแปลงเมตรเป็นกิโลเมตร", () => {
|
||||
const parsed = parseOsrmTable([[0, 16989.1, 3576.3]]);
|
||||
expect(parsed).toHaveLength(2);
|
||||
expect(parsed[0]).toBeCloseTo(16.9891, 4);
|
||||
expect(parsed[1]).toBeCloseTo(3.5763, 4);
|
||||
});
|
||||
|
||||
it("ค่า null จาก OSRM กลายเป็น null", () => {
|
||||
expect(parseOsrmTable([[0, null, 1000]])).toEqual([null, 1]);
|
||||
});
|
||||
|
||||
it("ข้อมูลผิดรูปแบบคืนอาร์เรย์ว่าง", () => {
|
||||
expect(parseOsrmTable(undefined)).toEqual([]);
|
||||
expect(parseOsrmTable("nope")).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatDistance", () => {
|
||||
it("แสดงทศนิยมหนึ่งตำแหน่ง", () => {
|
||||
expect(formatDistance({ distance_km: 2.44, source: "road" }, "—")).toBe(
|
||||
"2.4 km.",
|
||||
);
|
||||
});
|
||||
|
||||
it("ค่าประมาณขึ้นต้นด้วย ≈", () => {
|
||||
expect(
|
||||
formatDistance({ distance_km: 16.99, source: "straight" }, "—"),
|
||||
).toBe("≈ 17.0 km.");
|
||||
});
|
||||
|
||||
it("ไม่มีข้อมูลใช้ข้อความสำรอง", () => {
|
||||
expect(formatDistance(undefined, "— km.")).toBe("— km.");
|
||||
});
|
||||
});
|
||||
|
||||
describe("sortByDistance", () => {
|
||||
const items = [{ slug: "far" }, { slug: "unknown" }, { slug: "near" }];
|
||||
const distances: Record<string, DistanceResult | undefined> = {
|
||||
far: { distance_km: 120, source: "road" },
|
||||
near: { distance_km: 0.8, source: "road" },
|
||||
};
|
||||
|
||||
it("เรียงใกล้สุดก่อน และโรงที่ไม่ทราบระยะทางไปท้ายสุด", () => {
|
||||
expect(sortByDistance(items, distances).map((item) => item.slug)).toEqual([
|
||||
"near",
|
||||
"far",
|
||||
"unknown",
|
||||
]);
|
||||
});
|
||||
|
||||
it("ไกล 100 กม. ก็ยังถูกเรียงตามระยะทาง ไม่ถูกตัดออก", () => {
|
||||
const sorted = sortByDistance(items, distances);
|
||||
expect(sorted).toHaveLength(items.length);
|
||||
});
|
||||
|
||||
it("ไม่แก้ไขอาร์เรย์ต้นฉบับ", () => {
|
||||
const original = [...items];
|
||||
sortByDistance(items, distances);
|
||||
expect(items).toEqual(original);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user