2019-08-15 00:47:55 +01:00
|
|
|
import { expect } from "chai";
|
|
|
|
|
|
|
|
import { Formatter } from "export/formatter";
|
|
|
|
|
2020-10-12 22:13:03 +01:00
|
|
|
import { MathRun } from "../math-run";
|
2019-08-15 00:47:55 +01:00
|
|
|
import { MathFraction } from "./math-fraction";
|
|
|
|
|
|
|
|
describe("MathFraction", () => {
|
|
|
|
describe("#constructor()", () => {
|
|
|
|
it("should create a MathFraction with correct root key", () => {
|
|
|
|
const mathFraction = new MathFraction({
|
2020-10-12 22:13:03 +01:00
|
|
|
numerator: new MathRun("2"),
|
|
|
|
denominator: new MathRun("2"),
|
2019-08-15 00:47:55 +01:00
|
|
|
});
|
|
|
|
const tree = new Formatter().format(mathFraction);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"m:f": [
|
|
|
|
{
|
|
|
|
"m:num": [
|
|
|
|
{
|
|
|
|
"m:r": [
|
|
|
|
{
|
|
|
|
"m:t": ["2"],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"m:den": [
|
|
|
|
{
|
|
|
|
"m:r": [
|
|
|
|
{
|
|
|
|
"m:t": ["2"],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|