Enable flashlight at sunset and switch primary night action
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { flashlightAfterSunUpdate } from '../src/controls/flashlight.ts';
|
||||
|
||||
test('sunset enables the flashlight once, preserves manual off, and resets at dawn', () => {
|
||||
assert.equal(flashlightAfterSunUpdate(false, undefined, 20), false);
|
||||
assert.equal(flashlightAfterSunUpdate(false, 1, -0.1), false, 'wait until the solar disc has set');
|
||||
assert.equal(flashlightAfterSunUpdate(false, -0.1, -1), true);
|
||||
assert.equal(flashlightAfterSunUpdate(false, -1, -2), false, 'manual off survives time updates');
|
||||
assert.equal(flashlightAfterSunUpdate(true, -2, -3), true);
|
||||
assert.equal(flashlightAfterSunUpdate(true, -3, 1), false);
|
||||
assert.equal(flashlightAfterSunUpdate(false, 1, -1), true, 'next night enables again');
|
||||
assert.equal(flashlightAfterSunUpdate(false, undefined, -10), true, 'nighttime arrival enables the torch');
|
||||
});
|
||||
Reference in New Issue
Block a user