mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-12-28 01:24:53 -05:00
Added tests for curseforge-version
This commit is contained in:
parent
d903dafa4f
commit
d4156be39e
1 changed files with 59 additions and 0 deletions
59
tests/unit/platforms/curseforge/curseforge-version.spec.ts
Normal file
59
tests/unit/platforms/curseforge/curseforge-version.spec.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
import { VersionType } from "@/utils/versioning/version-type";
|
||||
import { FileInfo } from "@/utils/io/file-info";
|
||||
import { CurseForgeDependencyType } from "@/platforms/curseforge/curseforge-dependency-type";
|
||||
import { packCurseForgeVersionInit, CurseForgeVersionInit } from "@/platforms/curseforge/curseforge-version";
|
||||
|
||||
describe("packCurseForgeVersionInit", () => {
|
||||
test("returns correct form data when parent file ID is provided", () => {
|
||||
const version: CurseForgeVersionInit = Object.freeze({
|
||||
project_id: 0,
|
||||
changelog: "Initial release",
|
||||
changelog_type: "markdown",
|
||||
name: "Version 1.0",
|
||||
version_type: VersionType.RELEASE,
|
||||
dependencies: [{ slug: "mod-id", type: CurseForgeDependencyType.REQUIRED_DEPENDENCY }],
|
||||
});
|
||||
const gameVersions = [1, 2, 3];
|
||||
const file = "path/to/file";
|
||||
const parentFileId = 123;
|
||||
|
||||
const result = packCurseForgeVersionInit(version, gameVersions, file, parentFileId);
|
||||
|
||||
expect(result.file).toBeInstanceOf(FileInfo);
|
||||
expect(result.metadata).toEqual({
|
||||
changelog: version.changelog,
|
||||
changelogType: version.changelog_type,
|
||||
displayName: result.file.name,
|
||||
parentFileID: parentFileId,
|
||||
gameVersions: undefined,
|
||||
releaseType: version.version_type,
|
||||
relations: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
test("returns correct form data when parent file ID is not provided", () => {
|
||||
const version: CurseForgeVersionInit = Object.freeze({
|
||||
project_id: 0,
|
||||
changelog: "Initial release",
|
||||
changelog_type: "markdown",
|
||||
name: "Version 1.0",
|
||||
version_type: VersionType.RELEASE,
|
||||
dependencies: [{ slug: "mod-id", type: CurseForgeDependencyType.REQUIRED_DEPENDENCY }],
|
||||
});
|
||||
const gameVersions = [1, 2, 3];
|
||||
const file = "path/to/file";
|
||||
|
||||
const result = packCurseForgeVersionInit(version, gameVersions, file);
|
||||
|
||||
expect(result.file).toBeInstanceOf(FileInfo);
|
||||
expect(result.metadata).toEqual({
|
||||
changelog: version.changelog,
|
||||
changelogType: version.changelog_type,
|
||||
displayName: version.name,
|
||||
parentFileID: undefined,
|
||||
gameVersions,
|
||||
releaseType: version.version_type,
|
||||
relations: { projects: version.dependencies },
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue