2023-06-05 00:33:43 +01:00
|
|
|
import { describe, expect, it } from "vitest";
|
2019-08-15 00:47:55 +01:00
|
|
|
|
2022-06-26 23:26:42 +01:00
|
|
|
import { Formatter } from "@export/formatter";
|
2019-08-15 00:47:55 +01:00
|
|
|
|
|
|
|
import { Math } from "./math";
|
|
|
|
import { MathRun } from "./math-run";
|
|
|
|
|
|
|
|
describe("Math", () => {
|
|
|
|
describe("#constructor()", () => {
|
|
|
|
it("should create a Math with correct root key", () => {
|
|
|
|
const math = new Math({
|
|
|
|
children: [],
|
|
|
|
});
|
|
|
|
const tree = new Formatter().format(math);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"m:oMath": {},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be able to add children", () => {
|
|
|
|
const math = new Math({
|
|
|
|
children: [new MathRun("2+2")],
|
|
|
|
});
|
|
|
|
const tree = new Formatter().format(math);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"m:oMath": [
|
|
|
|
{
|
|
|
|
"m:r": [
|
|
|
|
{
|
|
|
|
"m:t": ["2+2"],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|