mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 19:11:58 +03:00
Merge a20c6554b0 into 37cfd2144b
This commit is contained in:
commit
d1b064f72d
1 changed files with 4 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import { describe, it, expect } from "vitest";
|
import { describe, it, expect } from "vitest";
|
||||||
import { toBase, fromBase, convertQ, attachUnit } from "./evaluator";
|
import { toBase, fromBase, convertQ, attachUnit } from "./evaluator";
|
||||||
import { qty, pct, EvalError, Decimal } from "./types";
|
import { qty, pct, EvalError, Decimal, Quantity } from "./types";
|
||||||
import { buildRegistry } from "./registry";
|
import { buildRegistry } from "./registry";
|
||||||
|
|
||||||
const reg = buildRegistry();
|
const reg = buildRegistry();
|
||||||
|
|
@ -77,9 +77,9 @@ describe("quantity conversion", () => {
|
||||||
expect(r1).toMatchObject({ kind: "quantity", unit: { id: "meter" } });
|
expect(r1).toMatchObject({ kind: "quantity", unit: { id: "meter" } });
|
||||||
|
|
||||||
// attaching matching dimension does conversion
|
// attaching matching dimension does conversion
|
||||||
const r2 = attachUnit(qty(2000, m), km);
|
const r2 = attachUnit(qty(2000, m), km) as Quantity;
|
||||||
expect((r2 as any).value.toNumber()).toBe(2);
|
expect(r2.value.toNumber()).toBe(2);
|
||||||
expect((r2 as any).unit?.id).toBe("kilo:meter");
|
expect(r2.unit?.id).toBe("kilo:meter");
|
||||||
|
|
||||||
// attaching mismatched dimension throws
|
// attaching mismatched dimension throws
|
||||||
expect(() => attachUnit(qty(1, m), kg)).toThrow(EvalError);
|
expect(() => attachUnit(qty(1, m), kg)).toThrow(EvalError);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue