This commit is contained in:
gili8420 2026-08-14 00:01:49 +09:00
commit b43955e0d9
162 changed files with 15425 additions and 0 deletions

View file

@ -0,0 +1,32 @@
import { describe, it, expect } from 'vitest';
import { pointDirty, templateDirty, DEFAULT_FLIGHT_PARAMETERS } from '$domain';
import type { FlightParameters, SavedPoint } from '$domain';
const point: SavedPoint = { id: 1, name: 'p', lat: 62.5, lon: 129.5, alt: 100 };
const paramsAt = (lat: number, lon: number, alt: number): FlightParameters => ({
...DEFAULT_FLIGHT_PARAMETERS,
launch_latitude: lat,
launch_longitude: lon,
launch_altitude: alt
});
describe('pointDirty', () => {
it('is clean when coordinates match the saved point', () => {
expect(pointDirty(paramsAt(62.5, 129.5, 100), point)).toBe(false);
});
it('is dirty when any coordinate diverges', () => {
expect(pointDirty(paramsAt(62.5001, 129.5, 100), point)).toBe(true);
expect(pointDirty(paramsAt(62.5, 129.5, 101), point)).toBe(true);
});
});
describe('templateDirty', () => {
it('is clean against an identical copy', () => {
const tpl = { ...DEFAULT_FLIGHT_PARAMETERS };
expect(templateDirty({ ...DEFAULT_FLIGHT_PARAMETERS }, tpl)).toBe(false);
});
it('is dirty when a parameter changes', () => {
const tpl = { ...DEFAULT_FLIGHT_PARAMETERS };
expect(templateDirty({ ...DEFAULT_FLIGHT_PARAMETERS, ascent_rate: 7 }, tpl)).toBe(true);
});
});