mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: add partial mocking (#8473)
* fix: add partial mocking * lint * Update packages/utils/export.test.ts
This commit is contained in:
parent
51ea184938
commit
6ff56c36e3
2 changed files with 8 additions and 10 deletions
|
@ -23,7 +23,6 @@ import { Excalidraw } from "../index";
|
||||||
import type { NormalizedZoomValue } from "../types";
|
import type { NormalizedZoomValue } from "../types";
|
||||||
import { ROUNDNESS } from "../constants";
|
import { ROUNDNESS } from "../constants";
|
||||||
import { vi } from "vitest";
|
import { vi } from "vitest";
|
||||||
import * as blob from "../data/blob";
|
|
||||||
import { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { getBoundTextElementPosition } from "../element/textElement";
|
import { getBoundTextElementPosition } from "../element/textElement";
|
||||||
import { createPasteEvent } from "../clipboard";
|
import { createPasteEvent } from "../clipboard";
|
||||||
|
@ -33,15 +32,15 @@ import { point, type Radians } from "../../math";
|
||||||
|
|
||||||
const { h } = window;
|
const { h } = window;
|
||||||
const mouse = new Pointer("mouse");
|
const mouse = new Pointer("mouse");
|
||||||
// This needs to fixed in vitest mock, as when importActual used with mock
|
|
||||||
// the tests hangs - https://github.com/vitest-dev/vitest/issues/546.
|
|
||||||
// But fortunately spying and mocking the return value of spy works :p
|
|
||||||
|
|
||||||
const resizeImageFileSpy = vi.spyOn(blob, "resizeImageFile");
|
vi.mock("../data/blob", async (actual) => {
|
||||||
const generateIdFromFileSpy = vi.spyOn(blob, "generateIdFromFile");
|
const orig: Object = await actual();
|
||||||
|
return {
|
||||||
resizeImageFileSpy.mockImplementation(async (imageFile: File) => imageFile);
|
...orig,
|
||||||
generateIdFromFileSpy.mockImplementation(async () => "fileId" as FileId);
|
resizeImageFile: (imageFile: File) => imageFile,
|
||||||
|
generateIdFromFile: () => "fileId" as FileId,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
// Unmount ReactDOM from root
|
// Unmount ReactDOM from root
|
||||||
|
|
|
@ -32,7 +32,6 @@ describe("exportToCanvas", async () => {
|
||||||
|
|
||||||
describe("exportToBlob", async () => {
|
describe("exportToBlob", async () => {
|
||||||
describe("mime type", () => {
|
describe("mime type", () => {
|
||||||
// afterEach(vi.restoreAllMocks);
|
|
||||||
it("should change image/jpg to image/jpeg", async () => {
|
it("should change image/jpg to image/jpeg", async () => {
|
||||||
const blob = await utils.exportToBlob({
|
const blob = await utils.exportToBlob({
|
||||||
...diagramFactory(),
|
...diagramFactory(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue