Skip to content

Commit

Permalink
Re-name variables (#2486)
Browse files Browse the repository at this point in the history
  • Loading branch information
dolanmiu committed Dec 29, 2023
1 parent ce0e993 commit fa40129
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
17 changes: 13 additions & 4 deletions src/file/paragraph/run/page-number.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { describe, expect, it } from "vitest";

import { Formatter } from "@export/formatter";

import { NumberOfPages, NumberOfPagesSection, Page } from "./page-number";
import { CurrentSection, NumberOfPages, NumberOfPagesSection, Page } from "./page-number";

describe("Page", () => {
describe("#constructor()", () => {
it("uses the font name for both ascii and hAnsi", () => {
it("should work", () => {
const tree = new Formatter().format(new Page());
expect(tree).to.deep.equal({ "w:instrText": [{ _attr: { "xml:space": "preserve" } }, "PAGE"] });
});
Expand All @@ -15,7 +15,7 @@ describe("Page", () => {

describe("NumberOfPages", () => {
describe("#constructor()", () => {
it("uses the font name for both ascii and hAnsi", () => {
it("should work", () => {
const tree = new Formatter().format(new NumberOfPages());
expect(tree).to.deep.equal({ "w:instrText": [{ _attr: { "xml:space": "preserve" } }, "NUMPAGES"] });
});
Expand All @@ -24,9 +24,18 @@ describe("NumberOfPages", () => {

describe("NumberOfPagesSection", () => {
describe("#constructor()", () => {
it("uses the font name for both ascii and hAnsi", () => {
it("should work", () => {
const tree = new Formatter().format(new NumberOfPagesSection());
expect(tree).to.deep.equal({ "w:instrText": [{ _attr: { "xml:space": "preserve" } }, "SECTIONPAGES"] });
});
});
});

describe("CurrentSection", () => {
describe("#constructor()", () => {
it("should work", () => {
const tree = new Formatter().format(new CurrentSection());
expect(tree).to.deep.equal({ "w:instrText": [{ _attr: { "xml:space": "preserve" } }, "SECTION"] });
});
});
});
2 changes: 1 addition & 1 deletion src/file/paragraph/run/page-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class NumberOfPagesSection extends XmlComponent {
}
}

export class CurrentPageInSection extends XmlComponent {
export class CurrentSection extends XmlComponent {
public constructor() {
super("w:instrText");
this.root.push(new TextAttributes({ space: SpaceType.PRESERVE }));
Expand Down
4 changes: 2 additions & 2 deletions src/file/paragraph/run/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FieldInstruction } from "@file/table-of-contents/field-instruction";

import { Break } from "./break";
import { Begin, End, Separate } from "./field";
import { NumberOfPages, NumberOfPagesSection, Page, CurrentPageInSection } from "./page-number";
import { NumberOfPages, NumberOfPagesSection, Page, CurrentSection } from "./page-number";
import { IRunPropertiesOptions, RunProperties } from "./properties";
import { Text } from "./run-components/text";
import {
Expand Down Expand Up @@ -146,7 +146,7 @@ export class Run extends XmlComponent {
break;
case PageNumber.CURRENT_SECTION:
this.root.push(new Begin());
this.root.push(new CurrentPageInSection());
this.root.push(new CurrentSection());
this.root.push(new Separate());
this.root.push(new End());
break;
Expand Down

0 comments on commit fa40129

Please sign in to comment.