Files
Battle-for-Tismo/tests/game_clock_test.js
T
2026-09-16 19:59:18 +02:00

26 lines
962 B
JavaScript

import { TestCase } from "./framework/test_case.js";
import { dateString, unixTime, START_UNIX_TIME, UNIX_SECONDS_PER_HOUR } from "../shared/game_clock.js";
export class GameClockTest extends TestCase {
test_starts_in_the_year_2000() {
this.assertEqual(dateString(0), "1 January 2000, 00:00");
}
test_advances_one_hour_at_a_time() {
this.assertEqual(dateString(1), "1 January 2000, 01:00");
this.assertEqual(dateString(24), "2 January 2000, 00:00");
this.assertEqual(dateString(48), "3 January 2000, 00:00");
}
test_a_full_year_passes_after_8760_hours() {
// The clock counts a fixed 365-day year but renders the real calendar, so
// 2000 (a leap year) ends on 31 December.
this.assertEqual(dateString(8760), "31 December 2000, 00:00");
}
test_unix_time_is_start_plus_hours() {
this.assertEqual(unixTime(0), START_UNIX_TIME);
this.assertEqual(unixTime(5), START_UNIX_TIME + 5 * UNIX_SECONDS_PER_HOUR);
}
}