Re-name paragraph styles

This commit is contained in:
Dolan
2020-11-06 00:27:57 +00:00
parent 610b2388bb
commit 74db67689f
6 changed files with 83 additions and 83 deletions

View File

@ -6,12 +6,12 @@ import { UnderlineType } from "file/paragraph/run/underline";
import { ShadingType } from "file/table";
import { EMPTY_OBJECT } from "file/xml-components";
import { ParagraphStyle } from "./paragraph-style";
import { StyleForParagraph } from "./paragraph-style";
describe("ParagraphStyle", () => {
describe("#constructor", () => {
it("should set the style type to paragraph and use the given style id", () => {
const style = new ParagraphStyle({ id: "myStyleId" });
const style = new StyleForParagraph({ id: "myStyleId" });
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": { _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
@ -19,7 +19,7 @@ describe("ParagraphStyle", () => {
});
it("should set the name of the style, if given", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
name: "Style Name",
});
@ -35,7 +35,7 @@ describe("ParagraphStyle", () => {
describe("formatting methods: style attributes", () => {
it("#basedOn", () => {
const style = new ParagraphStyle({ id: "myStyleId", basedOn: "otherId" });
const style = new StyleForParagraph({ id: "myStyleId", basedOn: "otherId" });
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
@ -46,7 +46,7 @@ describe("ParagraphStyle", () => {
});
it("#quickFormat", () => {
const style = new ParagraphStyle({ id: "myStyleId", quickFormat: true });
const style = new StyleForParagraph({ id: "myStyleId", quickFormat: true });
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
@ -62,7 +62,7 @@ describe("ParagraphStyle", () => {
});
it("#next", () => {
const style = new ParagraphStyle({ id: "myStyleId", next: "otherId" });
const style = new StyleForParagraph({ id: "myStyleId", next: "otherId" });
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
@ -75,7 +75,7 @@ describe("ParagraphStyle", () => {
describe("formatting methods: paragraph properties", () => {
it("#indent", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
indent: { left: 720 },
@ -93,7 +93,7 @@ describe("ParagraphStyle", () => {
});
it("#spacing", () => {
const style = new ParagraphStyle({ id: "myStyleId", paragraph: { spacing: { before: 50, after: 150 } } });
const style = new StyleForParagraph({ id: "myStyleId", paragraph: { spacing: { before: 50, after: 150 } } });
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
@ -106,7 +106,7 @@ describe("ParagraphStyle", () => {
});
it("#center", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
alignment: AlignmentType.CENTER,
@ -124,7 +124,7 @@ describe("ParagraphStyle", () => {
});
it("#character spacing", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
characterSpacing: 24,
@ -142,7 +142,7 @@ describe("ParagraphStyle", () => {
});
it("#left", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
alignment: AlignmentType.LEFT,
@ -160,7 +160,7 @@ describe("ParagraphStyle", () => {
});
it("#right", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
alignment: AlignmentType.RIGHT,
@ -178,7 +178,7 @@ describe("ParagraphStyle", () => {
});
it("#justified", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
alignment: AlignmentType.JUSTIFIED,
@ -196,7 +196,7 @@ describe("ParagraphStyle", () => {
});
it("#thematicBreak", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
thematicBreak: true,
@ -229,7 +229,7 @@ describe("ParagraphStyle", () => {
});
it("#contextualSpacing", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
contextualSpacing: true,
@ -255,7 +255,7 @@ describe("ParagraphStyle", () => {
});
it("#leftTabStop", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
leftTabStop: 1200,
@ -277,7 +277,7 @@ describe("ParagraphStyle", () => {
});
it("#maxRightTabStop", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
rightTabStop: TabStopPosition.MAX,
@ -299,7 +299,7 @@ describe("ParagraphStyle", () => {
});
it("#keepLines", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
keepLines: true,
@ -320,7 +320,7 @@ describe("ParagraphStyle", () => {
});
it("#keepNext", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
keepNext: true,
@ -341,7 +341,7 @@ describe("ParagraphStyle", () => {
});
it("#outlineLevel", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
paragraph: {
outlineLevel: 1,
@ -381,7 +381,7 @@ describe("ParagraphStyle", () => {
];
sizeTests.forEach(({ size, sizeComplexScript, expected }) => {
it(`#size ${size} cs ${sizeComplexScript}`, () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: { size, sizeComplexScript },
});
@ -393,7 +393,7 @@ describe("ParagraphStyle", () => {
});
it("#smallCaps", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
smallCaps: true,
@ -411,7 +411,7 @@ describe("ParagraphStyle", () => {
});
it("#allCaps", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
allCaps: true,
@ -429,7 +429,7 @@ describe("ParagraphStyle", () => {
});
it("#strike", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
strike: true,
@ -447,7 +447,7 @@ describe("ParagraphStyle", () => {
});
it("#doubleStrike", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
doubleStrike: true,
@ -465,7 +465,7 @@ describe("ParagraphStyle", () => {
});
it("#subScript", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
subScript: true,
@ -483,7 +483,7 @@ describe("ParagraphStyle", () => {
});
it("#superScript", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
superScript: true,
@ -501,7 +501,7 @@ describe("ParagraphStyle", () => {
});
it("#font by name", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
font: "Times",
@ -530,7 +530,7 @@ describe("ParagraphStyle", () => {
});
it("#font for ascii and eastAsia", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
font: {
@ -577,7 +577,7 @@ describe("ParagraphStyle", () => {
];
boldTests.forEach(({ bold, boldComplexScript, expected }) => {
it(`#bold ${bold} cs ${boldComplexScript}`, () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: { bold, boldComplexScript },
});
@ -606,7 +606,7 @@ describe("ParagraphStyle", () => {
];
italicsTests.forEach(({ italics, italicsComplexScript, expected }) => {
it(`#italics ${italics} cs ${italicsComplexScript}`, () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: { italics, italicsComplexScript },
});
@ -640,7 +640,7 @@ describe("ParagraphStyle", () => {
];
highlightTests.forEach(({ highlight, highlightComplexScript, expected }) => {
it(`#highlight ${highlight} cs ${highlightComplexScript}`, () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: { highlight, highlightComplexScript },
});
@ -714,7 +714,7 @@ describe("ParagraphStyle", () => {
];
shadingTests.forEach(({ shadow, shading, shadingComplexScript, expected }) => {
it("#shadow correctly", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: { shadow, shading, shadingComplexScript },
});
@ -727,7 +727,7 @@ describe("ParagraphStyle", () => {
describe("#underline", () => {
it("should set underline to 'single' if no arguments are given", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
underline: {},
@ -745,7 +745,7 @@ describe("ParagraphStyle", () => {
});
it("should set the style if given", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
underline: {
@ -765,7 +765,7 @@ describe("ParagraphStyle", () => {
});
it("should set the style and color if given", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
underline: {
@ -788,7 +788,7 @@ describe("ParagraphStyle", () => {
describe("#emphasisMark", () => {
it("should set emphasisMark to 'dot' if no arguments are given", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
emphasisMark: {},
@ -806,7 +806,7 @@ describe("ParagraphStyle", () => {
});
it("should set the style if given", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
emphasisMark: {
@ -827,7 +827,7 @@ describe("ParagraphStyle", () => {
});
it("#color", () => {
const style = new ParagraphStyle({
const style = new StyleForParagraph({
id: "myStyleId",
run: {
color: "123456",
@ -845,7 +845,7 @@ describe("ParagraphStyle", () => {
});
it("#link", () => {
const style = new ParagraphStyle({ id: "myStyleId", link: "MyLink" });
const style = new StyleForParagraph({ id: "myStyleId", link: "MyLink" });
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
@ -861,7 +861,7 @@ describe("ParagraphStyle", () => {
});
it("#semiHidden", () => {
const style = new ParagraphStyle({ id: "myStyleId", semiHidden: true });
const style = new StyleForParagraph({ id: "myStyleId", semiHidden: true });
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
@ -877,7 +877,7 @@ describe("ParagraphStyle", () => {
});
it("#uiPriority", () => {
const style = new ParagraphStyle({ id: "myStyleId", uiPriority: 99 });
const style = new StyleForParagraph({ id: "myStyleId", uiPriority: 99 });
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
@ -894,7 +894,7 @@ describe("ParagraphStyle", () => {
});
it("#unhideWhenUsed", () => {
const style = new ParagraphStyle({ id: "myStyleId", unhideWhenUsed: true });
const style = new StyleForParagraph({ id: "myStyleId", unhideWhenUsed: true });
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [