mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
refactor: 🚨 Don't use wildcard imports
This commit is contained in:
parent
bec3e4ea70
commit
53688095cc
|
|
@ -12,8 +12,8 @@ import {
|
||||||
mock,
|
mock,
|
||||||
spyOn,
|
spyOn,
|
||||||
} from "bun:test";
|
} from "bun:test";
|
||||||
import * as fs from "node:fs/promises";
|
import { rm } from "node:fs/promises";
|
||||||
import * as path from "node:path";
|
import { join } from "node:path";
|
||||||
import type { Config } from "~/packages/config-manager/config.type";
|
import type { Config } from "~/packages/config-manager/config.type";
|
||||||
import type { MediaHasher } from "../media-hasher";
|
import type { MediaHasher } from "../media-hasher";
|
||||||
import { DiskMediaDriver } from "./disk";
|
import { DiskMediaDriver } from "./disk";
|
||||||
|
|
@ -67,12 +67,12 @@ describe("DiskMediaDriver", () => {
|
||||||
|
|
||||||
expect(mockMediaHasher.getMediaHash).toHaveBeenCalledWith(file);
|
expect(mockMediaHasher.getMediaHash).toHaveBeenCalledWith(file);
|
||||||
expect(bunWriteSpy).toHaveBeenCalledWith(
|
expect(bunWriteSpy).toHaveBeenCalledWith(
|
||||||
path.join("/test/uploads", "testhash", "test.webp"),
|
join("/test/uploads", "testhash", "test.webp"),
|
||||||
expect.any(ArrayBuffer),
|
expect.any(ArrayBuffer),
|
||||||
);
|
);
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
uploadedFile: file,
|
uploadedFile: file,
|
||||||
path: path.join("testhash", "test.webp"),
|
path: join("testhash", "test.webp"),
|
||||||
hash: "testhash",
|
hash: "testhash",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -103,7 +103,7 @@ describe("DiskMediaDriver", () => {
|
||||||
|
|
||||||
expect(databaseHashFetcher).toHaveBeenCalledWith(hash);
|
expect(databaseHashFetcher).toHaveBeenCalledWith(hash);
|
||||||
expect(Bun.file).toHaveBeenCalledWith(
|
expect(Bun.file).toHaveBeenCalledWith(
|
||||||
path.join("/test/uploads", "test.webp"),
|
join("/test/uploads", "test.webp"),
|
||||||
);
|
);
|
||||||
expect(result).toBeInstanceOf(File);
|
expect(result).toBeInstanceOf(File);
|
||||||
expect(result?.name).toBe("test.webp");
|
expect(result?.name).toBe("test.webp");
|
||||||
|
|
@ -114,9 +114,7 @@ describe("DiskMediaDriver", () => {
|
||||||
const filename = "test.webp";
|
const filename = "test.webp";
|
||||||
const result = await diskDriver.getFile(filename);
|
const result = await diskDriver.getFile(filename);
|
||||||
|
|
||||||
expect(Bun.file).toHaveBeenCalledWith(
|
expect(Bun.file).toHaveBeenCalledWith(join("/test/uploads", filename));
|
||||||
path.join("/test/uploads", filename),
|
|
||||||
);
|
|
||||||
expect(result).toBeInstanceOf(File);
|
expect(result).toBeInstanceOf(File);
|
||||||
expect(result?.name).toBe(filename);
|
expect(result?.name).toBe(filename);
|
||||||
expect(result?.type).toBe("image/webp");
|
expect(result?.type).toBe("image/webp");
|
||||||
|
|
@ -126,9 +124,8 @@ describe("DiskMediaDriver", () => {
|
||||||
const url = "http://localhost:3000/uploads/testhash/test.webp";
|
const url = "http://localhost:3000/uploads/testhash/test.webp";
|
||||||
await diskDriver.deleteFileByUrl(url);
|
await diskDriver.deleteFileByUrl(url);
|
||||||
|
|
||||||
expect(fs.rm).toHaveBeenCalledWith(
|
expect(rm).toHaveBeenCalledWith(join("/test/uploads", "testhash"), {
|
||||||
path.join("/test/uploads", "testhash"),
|
recursive: true,
|
||||||
{ recursive: true },
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue