Fix tests and build

Remove unused code and dependencies
This commit is contained in:
Dolan Miu
2023-06-08 13:30:31 +01:00
parent a0a88412ff
commit 09ab91eeef
19 changed files with 22322 additions and 26082 deletions

View File

@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import * as sinon from "sinon";
import { describe, expect, it, vi } from "vitest";
import { FooterWrapper } from "./footer-wrapper";
import { Media } from "./media";
@ -10,15 +9,15 @@ describe("FooterWrapper", () => {
describe("#add", () => {
it("should call the underlying footer's addParagraph", () => {
const file = new FooterWrapper(new Media(), 1);
const spy = sinon.spy(file.View, "add");
const spy = vi.spyOn(file.View, "add");
file.add(new Paragraph({}));
expect(spy.called).to.equal(true);
expect(spy).toBeCalled();
});
it("should call the underlying footer's addParagraph", () => {
const file = new FooterWrapper(new Media(), 1);
const spy = sinon.spy(file.View, "add");
const spy = vi.spyOn(file.View, "add");
file.add(
new Table({
rows: [
@ -33,18 +32,18 @@ describe("FooterWrapper", () => {
}),
);
expect(spy.called).to.equal(true);
expect(spy).toBeCalled();
});
});
describe("#addChildElement", () => {
it("should call the underlying footer's addChildElement", () => {
const file = new FooterWrapper(new Media(), 1);
const spy = sinon.spy(file.View, "addChildElement");
const spy = vi.spyOn(file.View, "addChildElement");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
file.addChildElement({} as any);
expect(spy.called).to.equal(true);
expect(spy).toBeCalled();
});
});

View File

@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import * as sinon from "sinon";
import { describe, expect, it, vi } from "vitest";
import { HeaderWrapper } from "./header-wrapper";
import { Media } from "./media";
@ -10,15 +9,15 @@ describe("HeaderWrapper", () => {
describe("#add", () => {
it("should call the underlying header's addChildElement for Paragraph", () => {
const wrapper = new HeaderWrapper(new Media(), 1);
const spy = sinon.spy(wrapper.View, "add");
const spy = vi.spyOn(wrapper.View, "add");
wrapper.add(new Paragraph({}));
expect(spy.called).to.equal(true);
expect(spy).toBeCalled();
});
it("should call the underlying header's addChildElement for Table", () => {
const wrapper = new HeaderWrapper(new Media(), 1);
const spy = sinon.spy(wrapper.View, "add");
const spy = vi.spyOn(wrapper.View, "add");
wrapper.add(
new Table({
rows: [
@ -33,18 +32,18 @@ describe("HeaderWrapper", () => {
}),
);
expect(spy.called).to.equal(true);
expect(spy).toBeCalled();
});
});
describe("#addChildElement", () => {
it("should call the underlying header's addChildElement", () => {
const file = new HeaderWrapper(new Media(), 1);
const spy = sinon.spy(file.View, "addChildElement");
const spy = vi.spyOn(file.View, "addChildElement");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
file.addChildElement({} as any);
expect(spy.called).to.equal(true);
expect(spy).toBeCalled();
});
});

View File

@ -1,5 +1,4 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import * as sinon from "sinon";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { Formatter } from "@export/formatter";
@ -43,15 +42,15 @@ describe("CommentReference", () => {
});
describe("Comment", () => {
let clock: sinon.SinonFakeTimers;
beforeEach(() => {
const now = new Date("1999-01-01T00:00:00.000Z");
clock = sinon.useFakeTimers(now.getTime());
vi.useFakeTimers({
now: now.getTime(),
});
});
afterEach(() => {
clock.restore();
vi.restoreAllMocks();
});
describe("#constructor()", () => {