Debian Codegraph @

frontend/test/end-to-end-validation.test.ts

raw
1 import { get as store_get } from "svelte/store";
2 import { test } from "uvu";
3 import assert from "uvu/assert";
4
5 import { getAPIValidators } from "../src/api/validators";
6 import { chartContext } from "../src/charts/context";
7 import {
8 currenciesScale,
9 sunburstScale,
10 treemapScale,
11 } from "../src/charts/helpers";
12 import { currencies, ledgerData } from "../src/stores";
13 import { conversions } from "../src/stores/chart";
14 import { initialiseLedgerData, loadJSONSnapshot } from "./helpers";
15
16 test.before(initialiseLedgerData);
17
18 test("validate ledger data", () => {
19 const res = store_get(ledgerData);
20
21 assert.equal(res.accounts[0], "Liabilities:US:Chase:Slate");
22
23 const $conversions = store_get(conversions);
24 assert.equal($conversions[0], "at_cost");
25
26 assert.equal(store_get(treemapScale).domain(), res.accounts);
27 assert.equal(store_get(sunburstScale).domain(), res.accounts);
28 assert.equal(
29 store_get(sunburstScale)("Liabilities:US:Chase:Slate"),
30 "rgb(126, 174, 253)",
31 );
32
33 const all_currencies = [
34 "USD",
35 "VACHR",
36 "IRAUSD",
37 "VBMPX",
38 "RGAGX",
39 "GLD",
40 "VEA",
41 "VHT",
42 "ITOT",
43 "ABC",
44 "XYZ",
45 ];
46 assert.equal(store_get(currencies), all_currencies);
47 // Operating currency first, then sorted
48 assert.equal(store_get(currenciesScale).domain().slice(0, 3), [
49 "USD",
50 "ABC",
51 "GLD",
52 ]);
53
54 assert.equal(store_get(chartContext).currencies, ["USD"]);
55 });
56
57 test("validate events", async () => {
58 const data = await loadJSONSnapshot("test_json_api-test_api-events.json");
59 const res = getAPIValidators.events(data);
60 assert.equal(res.unwrap()[0]?.type, "employer");
61 });
62
63 test.run();