feat: v0.1.0 — scaffold + MapLibre map with EU airports
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { pitchForZoom, smoothstep, PITCH_ZOOM_MIN, PITCH_ZOOM_MAX, MAX_PITCH_DEG } from './camera';
|
||||
|
||||
describe('smoothstep', () => {
|
||||
it('clamps outside the edges and is 0.5 at the midpoint', () => {
|
||||
expect(smoothstep(0, 1, -5)).toBe(0);
|
||||
expect(smoothstep(0, 1, 2)).toBe(1);
|
||||
expect(smoothstep(0, 1, 0.5)).toBeCloseTo(0.5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('pitchForZoom', () => {
|
||||
it('is 0 at and below the lower zoom threshold', () => {
|
||||
expect(pitchForZoom(PITCH_ZOOM_MIN)).toBe(0);
|
||||
expect(pitchForZoom(4)).toBe(0);
|
||||
expect(pitchForZoom(0)).toBe(0);
|
||||
});
|
||||
|
||||
it('is max pitch at and above the upper zoom threshold', () => {
|
||||
expect(pitchForZoom(PITCH_ZOOM_MAX)).toBe(MAX_PITCH_DEG);
|
||||
expect(pitchForZoom(15)).toBe(MAX_PITCH_DEG);
|
||||
});
|
||||
|
||||
it('rises smoothly between thresholds (monotonic, midpoint = half max)', () => {
|
||||
expect(pitchForZoom((PITCH_ZOOM_MIN + PITCH_ZOOM_MAX) / 2)).toBeCloseTo(MAX_PITCH_DEG / 2);
|
||||
let prev = -1;
|
||||
for (let z = PITCH_ZOOM_MIN; z <= PITCH_ZOOM_MAX; z += 0.25) {
|
||||
const p = pitchForZoom(z);
|
||||
expect(p).toBeGreaterThan(prev);
|
||||
prev = p;
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user