Files
docx-js/src/file/paragraph/math/n-ary/math-n-ary-properties.spec.ts

150 lines
4.6 KiB
TypeScript
Raw Normal View History

2023-06-05 00:33:43 +01:00
import { describe, expect, it } from "vitest";
2019-08-20 20:40:40 +01:00
import { Formatter } from "@export/formatter";
2019-08-20 20:40:40 +01:00
import { createMathNAryProperties } from "./math-n-ary-properties";
2019-08-20 20:40:40 +01:00
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", () => {
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", () => {
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", () => {
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", () => {
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
});
});