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

134 lines
4.2 KiB
TypeScript
Raw Normal View History

2019-08-20 20:40:40 +01:00
import { expect } from "chai";
import { Formatter } from "@export/formatter";
2019-08-20 20:40:40 +01:00
import { MathNArayProperties } from "./math-naray-properties";
describe("MathNArayProperties", () => {
describe("#constructor()", () => {
it("should create a MathNArayProperties with correct root key", () => {
2020-10-10 13:41:26 +01:00
const mathNArayProperties = new MathNArayProperties("∑", true, true);
2019-08-20 20:40:40 +01:00
const tree = new Formatter().format(mathNArayProperties);
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 mathNArayProperties = new MathNArayProperties("∑", false, true);
const tree = new Formatter().format(mathNArayProperties);
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 mathNArayProperties = new MathNArayProperties("∑", true, false);
const tree = new Formatter().format(mathNArayProperties);
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 mathNArayProperties = new MathNArayProperties("∑", false, false);
const tree = new Formatter().format(mathNArayProperties);
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
});
});