mc-publish/test/modrinth-utils.test.ts
Fx Morin bf3f3c7c01
Modrinth Dependencies (#8)
* temp Modrinth Dependencies

* Fix final issues

* Got to love git sometimes

* Made test case for modrinth-utils

* That's why testing is important kids

* Included dependencies are still dependencies

* Naming

* Moved to Modrinth API v2

Co-authored-by: Kir_Antipov <kp.antipov@gmail.com>
2022-06-05 17:28:41 +03:00

37 lines
1.1 KiB
TypeScript

import { jest, describe, test, expect } from "@jest/globals";
import { getProject } from "../src/utils/modrinth-utils";
describe("getProject", () => {
test("returned versions have expected ids", async () => {
jest.setTimeout(15000);
const projects = {
"sodium": "AANobbMI",
"fabric-api": "P7dR8mSH",
"sync-fabric": "OrJTMhHF",
"nether-chest": "okOUGirG",
"ebe": "OVuFYfre",
};
for (const [slug, id] of Object.entries(projects)) {
const project = await getProject(slug);
expect(project).toHaveProperty("id", id);
}
});
test("the method returns null if project with the given slug does not exist", async () => {
jest.setTimeout(15000);
const nonExistentProjects = [
"Na-11",
"api-fabric",
"sync-forge",
"ever-chest",
"beb",
"i-swear-to-god-if-someone-registers-these-mods"
];
for (const slug of nonExistentProjects) {
const project = await getProject(slug);
expect(project).toBeNull();
}
});
});