Files
Battle-for-Tismo/tests/text_format_test.js
T

27 lines
1.0 KiB
JavaScript

import { TestCase } from "./framework/test_case.js";
import { groupDigits, compact, hours, improvements } from "../shared/text_format.js";
export class TextFormatTest extends TestCase {
test_number_and_list_formatting() {
this.assertEqual(groupDigits(0), "0");
this.assertEqual(groupDigits(123), "123");
// The separators are non-breaking spaces, so a number never wraps.
this.assertEqual(groupDigits(1234), "1\u00a0234");
this.assertEqual(groupDigits(1234567), "1\u00a0234\u00a0567");
this.assertEqual(groupDigits(-1234), "-1\u00a0234");
this.assertEqual(compact(0), "0");
this.assertEqual(compact(999), "999");
this.assertEqual(compact(1234), "1.23K");
this.assertEqual(compact(1234567), "1.23M");
this.assertEqual(compact(999950), "1M");
this.assertEqual(compact(-2500), "-2.5K");
this.assertEqual(hours(0.5), "0.50 h");
this.assertEqual(hours(2.25), "2.3 h");
this.assertEqual(improvements([]), "None");
this.assertEqual(improvements(["Eiffel Tower", "Louvre"]), "Eiffel Tower, Louvre");
}
}