tests: fixup tests and linting issues

This commit is contained in:
Maxim Fedorenko
2023-05-04 12:30:31 +03:00
parent a0437381e7
commit e77a7dfdcd
5 changed files with 20 additions and 20 deletions

View File

@ -1,8 +1,6 @@
import { assert, expect } from "chai"; import { assert, expect } from "chai";
import { SinonStub, stub } from "sinon";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";
import * as convenienceFunctions from "@util/convenience-functions";
import { Utility } from "tests/utility"; import { Utility } from "tests/utility";
@ -458,7 +456,7 @@ describe("Anchor", () => {
"wp:docPr": { "wp:docPr": {
_attr: { _attr: {
descr: "test", descr: "test",
id: 0, id: 1,
name: "test", name: "test",
title: "test", title: "test",
}, },

View File

@ -1,9 +1,7 @@
import { expect } from "chai"; import { expect } from "chai";
import { SinonStub, stub } from "sinon";
import { IContext } from "@file/xml-components"; import { IContext } from "@file/xml-components";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";
import * as convenienceFunctions from "@util/convenience-functions";
import { ConcreteHyperlink, TextRun } from "../"; import { ConcreteHyperlink, TextRun } from "../";
import { Drawing, IDrawingOptions } from "./drawing"; import { Drawing, IDrawingOptions } from "./drawing";
@ -70,7 +68,7 @@ describe("Drawing", () => {
"wp:docPr": { "wp:docPr": {
_attr: { _attr: {
descr: "", descr: "",
id: 0, id: 1,
name: "", name: "",
title: "", title: "",
}, },
@ -301,7 +299,7 @@ describe("Drawing", () => {
"wp:docPr": { "wp:docPr": {
_attr: { _attr: {
descr: "", descr: "",
id: 0, id: 1,
name: "", name: "",
title: "", title: "",
}, },
@ -535,7 +533,7 @@ describe("Drawing", () => {
{ {
_attr: { _attr: {
descr: "", descr: "",
id: 0, id: 1,
name: "", name: "",
title: "", title: "",
}, },

View File

@ -1,8 +1,6 @@
import { expect } from "chai"; import { expect } from "chai";
import { SinonStub, stub } from "sinon";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";
import * as convenienceFunctions from "@util/convenience-functions";
import { Numbering } from "./numbering"; import { Numbering } from "./numbering";
@ -18,7 +16,7 @@ describe("Numbering", () => {
const abstractNums = tree["w:numbering"].filter((el) => el["w:abstractNum"]); const abstractNums = tree["w:numbering"].filter((el) => el["w:abstractNum"]);
expect(abstractNums).to.have.lengthOf(1); expect(abstractNums).to.have.lengthOf(1);
expect(abstractNums[0]["w:abstractNum"]).to.deep.include.members([ expect(abstractNums[0]["w:abstractNum"]).to.deep.include.members([
{ _attr: { "w:abstractNumId": 0, "w15:restartNumberingAfterBreak": 0 } }, { _attr: { "w:abstractNumId": 1, "w15:restartNumberingAfterBreak": 0 } },
{ "w:multiLevelType": { _attr: { "w:val": "hybridMultilevel" } } }, { "w:multiLevelType": { _attr: { "w:val": "hybridMultilevel" } } },
]); ]);

View File

@ -124,7 +124,7 @@ describe("ImageRun", () => {
"wp:docPr": { "wp:docPr": {
_attr: { _attr: {
descr: "", descr: "",
id: 0, id: 1,
name: "", name: "",
title: "", title: "",
}, },
@ -376,7 +376,7 @@ describe("ImageRun", () => {
"wp:docPr": { "wp:docPr": {
_attr: { _attr: {
descr: "", descr: "",
id: 0, id: 1,
name: "", name: "",
title: "", title: "",
}, },
@ -632,7 +632,7 @@ describe("ImageRun", () => {
"wp:docPr": { "wp:docPr": {
_attr: { _attr: {
descr: "", descr: "",
id: 0, id: 1,
name: "", name: "",
title: "", title: "",
}, },
@ -891,7 +891,7 @@ describe("ImageRun", () => {
"wp:docPr": { "wp:docPr": {
_attr: { _attr: {
descr: "", descr: "",
id: 0, id: 1,
name: "", name: "",
title: "", title: "",
}, },

View File

@ -5,15 +5,21 @@ export const convertMillimetersToTwip = (millimeters: number): number => Math.fl
export const convertInchesToTwip = (inches: number): number => Math.floor(inches * 72 * 20); export const convertInchesToTwip = (inches: number): number => Math.floor(inches * 72 * 20);
export const uniqueNumericIdCreator = (initial = 0): (() => number) => { export type UniqueNumericIdCreator = () => number;
export const uniqueNumericIdCreator = (initial = 0): UniqueNumericIdCreator => {
let currentCount = initial; let currentCount = initial;
return () => ++currentCount; return () => ++currentCount;
}; };
export const abstractNumUniqueNumericIdGen = () => uniqueNumericIdCreator(); export const abstractNumUniqueNumericIdGen = (): UniqueNumericIdCreator => uniqueNumericIdCreator();
export const concreteNumUniqueNumericIdGen = () => uniqueNumericIdCreator(1); // Setting initial to 1 as we have numId = 1 for "default-bullet-numbering"
export const docPropertiesUniqueNumericIdGen = () => uniqueNumericIdCreator(); // Setting initial to 1 as we have numId = 1 for "default-bullet-numbering"
export const bookmarkUniqueNumericIdGen = () => uniqueNumericIdCreator(); export const concreteNumUniqueNumericIdGen = (): UniqueNumericIdCreator => uniqueNumericIdCreator(1);
export const docPropertiesUniqueNumericIdGen = (): UniqueNumericIdCreator => uniqueNumericIdCreator();
export const bookmarkUniqueNumericIdGen = (): UniqueNumericIdCreator => uniqueNumericIdCreator();
export const uniqueId = (): string => nanoid().toLowerCase(); export const uniqueId = (): string => nanoid().toLowerCase();