2023-06-05 00:33:43 +01:00
|
|
|
import { describe, expect, it } from "vitest";
|
2019-08-20 20:40:40 +01:00
|
|
|
|
2022-06-26 23:26:42 +01:00
|
|
|
import { Formatter } from "@export/formatter";
|
2019-08-20 20:40:40 +01:00
|
|
|
|
2025-04-14 16:43:15 +05:30
|
|
|
import { createMathNAryProperties } from "./math-n-ary-properties";
|
2019-08-20 20:40:40 +01:00
|
|
|
|
2025-04-14 16:43:15 +05:30
|
|
|
describe("createMathNAryProperties", () => {
|
2019-08-20 20:40:40 +01:00
|
|
|
describe("#constructor()", () => {
|
2022-07-05 05:06:32 +01:00
|
|
|
it("should create a MathNAryProperties with correct root key", () => {
|
2025-04-14 16:43:15 +05:30
|
|
|
const mathNAryProperties = createMathNAryProperties({
|
|
|
|
accent: "∑",
|
|
|
|
hasSuperScript: true,
|
|
|
|
hasSubScript: true,
|
|
|
|
});
|
2019-08-20 20:40:40 +01:00
|
|
|
|
2022-07-05 05:06:32 +01:00
|
|
|
const tree = new Formatter().format(mathNAryProperties);
|
2019-08-20 20:40:40 +01:00
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"m:naryPr": [
|
|
|
|
{
|
|
|
|
"m:chr": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": "∑",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"m:limLoc": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": "undOvr",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
2020-10-10 13:41:26 +01:00
|
|
|
|
|
|
|
it("should add super-script hide attributes", () => {
|
2025-04-14 16:43:15 +05:30
|
|
|
const mathNAryProperties = createMathNAryProperties({
|
|
|
|
accent: "∑",
|
|
|
|
hasSuperScript: false,
|
|
|
|
hasSubScript: true,
|
|
|
|
});
|
2020-10-10 13:41:26 +01:00
|
|
|
|
2022-07-05 05:06:32 +01:00
|
|
|
const tree = new Formatter().format(mathNAryProperties);
|
2020-10-10 13:41:26 +01:00
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"m:naryPr": [
|
|
|
|
{
|
|
|
|
"m:chr": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": "∑",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"m:limLoc": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": "undOvr",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"m:supHide": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add sub-script hide attributes", () => {
|
2025-04-14 16:43:15 +05:30
|
|
|
const mathNAryProperties = createMathNAryProperties({
|
|
|
|
accent: "∑",
|
|
|
|
hasSuperScript: true,
|
|
|
|
hasSubScript: false,
|
|
|
|
});
|
2020-10-10 13:41:26 +01:00
|
|
|
|
2022-07-05 05:06:32 +01:00
|
|
|
const tree = new Formatter().format(mathNAryProperties);
|
2020-10-10 13:41:26 +01:00
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"m:naryPr": [
|
|
|
|
{
|
|
|
|
"m:chr": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": "∑",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"m:limLoc": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": "undOvr",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"m:subHide": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add both super-script and sub-script hide attributes", () => {
|
2025-04-14 16:43:15 +05:30
|
|
|
const mathNAryProperties = createMathNAryProperties({
|
|
|
|
accent: "∑",
|
|
|
|
hasSuperScript: false,
|
|
|
|
hasSubScript: false,
|
|
|
|
});
|
2020-10-10 13:41:26 +01:00
|
|
|
|
2022-07-05 05:06:32 +01:00
|
|
|
const tree = new Formatter().format(mathNAryProperties);
|
2020-10-10 13:41:26 +01:00
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"m:naryPr": [
|
|
|
|
{
|
|
|
|
"m:chr": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": "∑",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"m:limLoc": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": "undOvr",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"m:supHide": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"m:subHide": {
|
|
|
|
_attr: {
|
|
|
|
"m:val": 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
2019-08-20 20:40:40 +01:00
|
|
|
});
|
|
|
|
});
|