aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/viewer/tests/skypanel.test.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/tests/skypanel.test.mjs')
-rw-r--r--viewer/tests/skypanel.test.mjs16
1 files changed, 16 insertions, 0 deletions
diff --git a/viewer/tests/skypanel.test.mjs b/viewer/tests/skypanel.test.mjs
new file mode 100644
index 0000000..c746bd8
--- /dev/null
+++ b/viewer/tests/skypanel.test.mjs
@@ -0,0 +1,16 @@
+import './_planet.mjs';
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { dayLabel, momentLabel, daylightLabel, SKY_LINES } from '../js/skypanel.js';
+
+test('labels', () => {
+ assert.equal(dayLabel(54), 'day 54 of 216 ยท northern midsummer');
+ assert.equal(dayLabel(30), 'day 30 of 216');
+ assert.equal(momentLabel(23328), 'moment 23,328 of 46,656');
+ assert.equal(daylightLabel(0, 30), 'daylight 50% (15.6 h)');
+});
+
+test('tropics and polar circles', () => {
+ assert.deepEqual(SKY_LINES.map(l => l[0].lat), [20, -20, 70, -70]);
+ assert.ok(SKY_LINES.every(l => l.length === 181 && l[0].lon === -180 && l.at(-1).lon === 180));
+});