Update vitest (#2475)
* Update vitest * Update vite test config * Fix coverage metrics and bump coverage
This commit is contained in:
2496
package-lock.json
generated
2496
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -73,8 +73,8 @@
|
||||
"@types/xml": "^1.0.8",
|
||||
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
||||
"@typescript-eslint/parser": "^6.9.1",
|
||||
"@vitest/coverage-v8": "^0.34.6",
|
||||
"@vitest/ui": "^0.34.7",
|
||||
"@vitest/coverage-v8": "^1.1.0",
|
||||
"@vitest/ui": "^1.1.0",
|
||||
"cspell": "^7.3.8",
|
||||
"docsify-cli": "^4.3.0",
|
||||
"eslint": "^8.23.0",
|
||||
@ -99,7 +99,7 @@
|
||||
"vite-plugin-dts": "^3.3.1",
|
||||
"vite-plugin-node-polyfills": "^0.9.0",
|
||||
"vite-tsconfig-paths": "^4.2.0",
|
||||
"vitest": "^0.33.0"
|
||||
"vitest": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
|
@ -1,5 +1,5 @@
|
||||
// http://officeopenxml.com/WPsectionLineNumbering.php
|
||||
import { NextAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
||||
import { decimalNumber, PositiveUniversalMeasure, twipsMeasureValue } from "@util/values";
|
||||
|
||||
// <xsd:simpleType name="ST_LineNumberRestart">
|
||||
@ -25,23 +25,17 @@ export const LineNumberRestartFormat = {
|
||||
// <xsd:attribute name="restart" type="ST_LineNumberRestart" use="optional" default="newPage"/>
|
||||
// </xsd:complexType>
|
||||
|
||||
export interface ILineNumberAttributes {
|
||||
export type ILineNumberAttributes = {
|
||||
readonly countBy?: number;
|
||||
readonly start?: number;
|
||||
readonly restart?: (typeof LineNumberRestartFormat)[keyof typeof LineNumberRestartFormat];
|
||||
readonly distance?: number | PositiveUniversalMeasure;
|
||||
}
|
||||
};
|
||||
|
||||
export class LineNumberType extends XmlComponent {
|
||||
public constructor({ countBy, start, restart, distance }: ILineNumberAttributes) {
|
||||
super("w:lnNumType");
|
||||
this.root.push(
|
||||
new NextAttributeComponent<{
|
||||
readonly countBy?: number;
|
||||
readonly start?: number;
|
||||
readonly restart?: (typeof LineNumberRestartFormat)[keyof typeof LineNumberRestartFormat];
|
||||
readonly distance?: number | PositiveUniversalMeasure;
|
||||
}>({
|
||||
export const createLineNumberType = ({ countBy, start, restart, distance }: ILineNumberAttributes): XmlComponent =>
|
||||
new BuilderElement<ILineNumberAttributes>({
|
||||
name: "w:lnNumType",
|
||||
attributes: {
|
||||
countBy: { key: "w:countBy", value: countBy === undefined ? undefined : decimalNumber(countBy) },
|
||||
start: { key: "w:start", value: start === undefined ? undefined : decimalNumber(start) },
|
||||
restart: { key: "w:restart", value: restart },
|
||||
@ -49,7 +43,5 @@ export class LineNumberType extends XmlComponent {
|
||||
key: "w:distance",
|
||||
value: distance === undefined ? undefined : twipsMeasureValue(distance),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -9,7 +9,7 @@ import { OnOffElement, XmlComponent } from "@file/xml-components";
|
||||
import { HeaderFooterReference, HeaderFooterReferenceType, HeaderFooterType } from "./properties/header-footer-reference";
|
||||
import { Columns, IColumnsAttributes } from "./properties/columns";
|
||||
import { DocumentGrid, IDocGridAttributesProperties } from "./properties/doc-grid";
|
||||
import { ILineNumberAttributes, LineNumberType } from "./properties/line-number";
|
||||
import { ILineNumberAttributes, createLineNumberType } from "./properties/line-number";
|
||||
import { IPageBordersOptions, PageBorders } from "./properties/page-borders";
|
||||
import { IPageMarginAttributes, PageMargin } from "./properties/page-margin";
|
||||
import { IPageNumberTypeAttributes, PageNumberType } from "./properties/page-number";
|
||||
@ -137,7 +137,7 @@ export class SectionProperties extends XmlComponent {
|
||||
}
|
||||
|
||||
if (lineNumbers) {
|
||||
this.root.push(new LineNumberType(lineNumbers));
|
||||
this.root.push(createLineNumberType(lineNumbers));
|
||||
}
|
||||
|
||||
this.root.push(new PageNumberType(pageNumbers));
|
||||
|
@ -2,7 +2,7 @@ import { SpaceType } from "@file/shared";
|
||||
import { XmlComponent } from "@file/xml-components";
|
||||
|
||||
import { TextAttributes } from "../run/text-attributes";
|
||||
import { IPageReferenceOptions } from "./pageref-properties";
|
||||
import { IPageReferenceOptions } from "./pageref";
|
||||
|
||||
export class PageReferenceFieldInstruction extends XmlComponent {
|
||||
public constructor(bookmarkId: string, options: IPageReferenceOptions = {}) {
|
||||
|
@ -1,16 +0,0 @@
|
||||
// Options according to https://www.ecma-international.org/publications/standards/Ecma-376.htm (at Part 1, Page 1234)
|
||||
|
||||
export interface IPageReferenceOptions {
|
||||
/**
|
||||
* \h option - Creates a hyperlink to the bookmarked paragraph.
|
||||
*/
|
||||
readonly hyperlink?: boolean;
|
||||
/**
|
||||
* \p option - Causes the field to display its position relative to the source
|
||||
* bookmark. If the PAGEREF field is on the same page as the
|
||||
* bookmark, it omits "on page #" and returns "above" or "below"
|
||||
* only. If the PAGEREF field is not on the same page as the
|
||||
* bookmark, the string "on page #" is used.
|
||||
*/
|
||||
readonly useRelativePosition?: boolean;
|
||||
}
|
@ -2,7 +2,22 @@
|
||||
import { Begin, End } from "@file/paragraph/run/field";
|
||||
import { Run } from "../run";
|
||||
import { PageReferenceFieldInstruction } from "./pageref-field-instruction";
|
||||
import type { IPageReferenceOptions } from "./pageref-properties";
|
||||
|
||||
// Options according to https://www.ecma-international.org/publications/standards/Ecma-376.htm (at Part 1, Page 1234)
|
||||
export type IPageReferenceOptions = {
|
||||
/**
|
||||
* \h option - Creates a hyperlink to the bookmarked paragraph.
|
||||
*/
|
||||
readonly hyperlink?: boolean;
|
||||
/**
|
||||
* \p option - Causes the field to display its position relative to the source
|
||||
* bookmark. If the PAGEREF field is on the same page as the
|
||||
* bookmark, it omits "on page #" and returns "above" or "below"
|
||||
* only. If the PAGEREF field is not on the same page as the
|
||||
* bookmark, the string "on page #" is used.
|
||||
*/
|
||||
readonly useRelativePosition?: boolean;
|
||||
};
|
||||
|
||||
export class PageReference extends Run {
|
||||
public constructor(bookmarkId: string, options: IPageReferenceOptions = {}) {
|
||||
|
@ -65,6 +65,8 @@ export class ImageRun extends Run {
|
||||
.map((c) => c.charCodeAt(0)),
|
||||
);
|
||||
} else {
|
||||
/* c8 ignore next 4 */
|
||||
// Not possible to test this branch in NodeJS
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
||||
const b = require("buf" + "fer");
|
||||
return new b.Buffer(dataURI, "base64");
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
import { configDefaults, defineConfig } from "vitest/config";
|
||||
import { resolve } from "path";
|
||||
import tsconfigPaths from "vite-tsconfig-paths";
|
||||
import dts from "vite-plugin-dts";
|
||||
@ -60,10 +60,31 @@ export default defineConfig({
|
||||
coverage: {
|
||||
provider: "v8",
|
||||
reporter: ["text", "json", "html"],
|
||||
statements: 99.93,
|
||||
branches: 98.85,
|
||||
thresholds: {
|
||||
statements: 99.96,
|
||||
branches: 98.98,
|
||||
functions: 100,
|
||||
lines: 99.93,
|
||||
lines: 99.96,
|
||||
},
|
||||
exclude: [
|
||||
...configDefaults.exclude,
|
||||
'**/build/**',
|
||||
'**/demo/**',
|
||||
'**/docs/**',
|
||||
'**/scripts/**',
|
||||
'**/src/**/index.ts',
|
||||
],
|
||||
},
|
||||
include: [
|
||||
'**/src/**/*.spec.ts',
|
||||
'**/packages/**/*.spec.ts'
|
||||
],
|
||||
exclude: [
|
||||
...configDefaults.exclude,
|
||||
'**/build/**',
|
||||
'**/demo/**',
|
||||
'**/docs/**',
|
||||
'**/scripts/**'
|
||||
],
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user