From 3443c1c65e9f1753e1e656b35d08416c1fa298f2 Mon Sep 17 00:00:00 2001 From: godosa Date: Wed, 7 Oct 2026 00:14:38 +0200 Subject: worldmap-viewer: initial public history --- viewer/tests/atmosphere.test.mjs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 viewer/tests/atmosphere.test.mjs (limited to 'viewer/tests/atmosphere.test.mjs') diff --git a/viewer/tests/atmosphere.test.mjs b/viewer/tests/atmosphere.test.mjs new file mode 100644 index 0000000..79f183a --- /dev/null +++ b/viewer/tests/atmosphere.test.mjs @@ -0,0 +1,24 @@ +import './_planet.mjs'; +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import './importmap.mjs'; + +const { atmosphere, SKY_FULL_KM, SKY_NONE_KM } = await import('../js/atmosphere.js'); +const lum = c => c[0] + c[1] + c[2]; + +test('full sky near the ground, none in space, a smooth fade between', () => { + assert.equal(atmosphere(5).amount, 1); + assert.equal(atmosphere(SKY_FULL_KM).amount, 1); + assert.equal(atmosphere(SKY_NONE_KM).amount, 0); + assert.equal(atmosphere(5000).amount, 0); + const m = atmosphere(60).amount; + assert.ok(m > 0.2 && m < 0.8); +}); + +test('day sky is blue, lighter at the horizon; night is dark; Sky off = day', () => { + const d = atmosphere(1, null); + assert.ok(d.zenith[2] > d.zenith[0] && lum(d.horizon) > lum(d.zenith)); + const n = atmosphere(1, -1); + assert.ok(lum(n.horizon) < 0.3 * lum(d.horizon)); + assert.deepEqual(atmosphere(1, 1), d); +}); -- cgit