Rebalanced the resource rules so nothing is priced primarily in money: steel, electricity and high-tech lead every construction bill, chip foundries are seeded everywhere instead of being hand-placed, and cities open with stores of steel and high-tech. City building rows now lead with the resource bill and keep the money as an aside, and the region's resources expand into the buildings that demand them. Pulled the graph and cost maths into a framework-free shared/economy_graph.js, quoted currency through one helper, and gave every data table the same striping and row highlight.
35 lines
1.2 KiB
JavaScript
35 lines
1.2 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_group_digits() {
|
|
this.assertEqual(groupDigits(0), "0");
|
|
this.assertEqual(groupDigits(7), "7");
|
|
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");
|
|
}
|
|
|
|
test_compact() {
|
|
this.assertEqual(compact(0), "0");
|
|
this.assertEqual(compact(7), "7");
|
|
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");
|
|
}
|
|
|
|
test_hours() {
|
|
this.assertEqual(hours(0.5), "0.50 h");
|
|
this.assertEqual(hours(2.25), "2.3 h");
|
|
}
|
|
|
|
test_improvements() {
|
|
this.assertEqual(improvements([]), "None");
|
|
this.assertEqual(improvements(["Eiffel Tower", "Louvre"]), "Eiffel Tower, Louvre");
|
|
}
|
|
}
|