mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-29 11:50:57 -05:00
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
|
import { zipFile } from "@/../tests/utils/zip-utils";
|
||
|
import mockFs from "mock-fs";
|
||
|
import { NeoForgeMetadata } from "@/loaders/neoforge/neoforge-metadata";
|
||
|
import { NeoForgeMetadataReader } from "@/loaders/neoforge/neoforge-metadata-reader";
|
||
|
|
||
|
beforeEach(async () => {
|
||
|
mockFs({
|
||
|
"neoforge.mod.jar": await zipFile([__dirname, "../../../content/neoforge/mods.toml"], "META-INF/mods.toml"),
|
||
|
"text.txt": "",
|
||
|
});
|
||
|
});
|
||
|
|
||
|
afterEach(() => {
|
||
|
mockFs.restore();
|
||
|
});
|
||
|
|
||
|
describe("NeoForgeMetadataReader", () => {
|
||
|
test("successfully reads mods.toml", async () => {
|
||
|
const reader = new NeoForgeMetadataReader();
|
||
|
|
||
|
const metadata = await reader.readMetadataFile("neoforge.mod.jar");
|
||
|
|
||
|
expect(metadata).toBeInstanceOf(NeoForgeMetadata);
|
||
|
});
|
||
|
|
||
|
test("throws if file is not a NeoForge mod", async () => {
|
||
|
const reader = new NeoForgeMetadataReader();
|
||
|
|
||
|
await expect(reader.readMetadataFile("text.txt")).rejects.toThrow();
|
||
|
});
|
||
|
|
||
|
test("throws if file does not exist", async () => {
|
||
|
const reader = new NeoForgeMetadataReader();
|
||
|
|
||
|
await expect(reader.readMetadataFile("text.json")).rejects.toThrow();
|
||
|
});
|
||
|
});
|