mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-02 11:58:12 +03:00
test: other cg converter tests
honestly these tests are super barebones but i mean they're good enough. I hate writing tests.
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
import { ConverterAPICGMuseca } from "./converter";
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import t from "tap";
|
||||
import { dmf } from "test-utils/misc";
|
||||
import type { CGContext, CGMusecaScore } from "../types";
|
||||
import type { DryScore } from "lib/score-import/framework/common/types";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
function mkInput(modifant: Partial<CGMusecaScore> = {}) {
|
||||
const validInput: CGMusecaScore = {
|
||||
internalId: 1, // ALBIDA (Remix) ADV
|
||||
difficulty: 0,
|
||||
dateTime: "2019-06-06 08:14:22",
|
||||
score: 912_000,
|
||||
version: 1,
|
||||
clearType: 2,
|
||||
critical: 100,
|
||||
near: 50,
|
||||
error: 10,
|
||||
maxChain: 300,
|
||||
scoreGrade: "whatever, this is unused",
|
||||
};
|
||||
|
||||
return dmf(validInput, modifant);
|
||||
}
|
||||
|
||||
// we use any here because it's not easy to allow deep partials
|
||||
function mkOutput(modifant: any = {}): DryScore<"museca:Single"> {
|
||||
const validOutput: DryScore<"museca:Single"> = {
|
||||
comment: null,
|
||||
game: "museca",
|
||||
importType: "api/cg-dev-museca",
|
||||
timeAchieved: 1559805262000,
|
||||
service: "dev",
|
||||
scoreData: {
|
||||
grade: "優",
|
||||
percent: 91.2,
|
||||
score: 912_000,
|
||||
lamp: "CLEAR",
|
||||
judgements: {
|
||||
critical: 100,
|
||||
near: 50,
|
||||
miss: 10,
|
||||
},
|
||||
hitMeta: {},
|
||||
},
|
||||
scoreMeta: {},
|
||||
};
|
||||
|
||||
return dmf(validOutput, modifant);
|
||||
}
|
||||
|
||||
t.test("#ConverterAPICGMuseca", (t) => {
|
||||
const context: CGContext = {
|
||||
service: "dev",
|
||||
userID: 1,
|
||||
};
|
||||
|
||||
const convert = (modifant: Partial<CGMusecaScore> = {}) =>
|
||||
ConverterAPICGMuseca(mkInput(modifant), context, "api/cg-dev-museca", logger);
|
||||
|
||||
t.test("Valid Input", async (t) => {
|
||||
const res = await convert();
|
||||
|
||||
t.hasStrict(res, {
|
||||
song: {
|
||||
id: 1,
|
||||
},
|
||||
chart: {
|
||||
difficulty: "Green",
|
||||
data: {
|
||||
inGameID: 1,
|
||||
},
|
||||
},
|
||||
dryScore: mkOutput(),
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Lamps", async (t) => {
|
||||
t.hasStrict(await convert({ score: 1_000_000 }), {
|
||||
dryScore: { scoreData: { lamp: "PERFECT CONNECT ALL" } },
|
||||
});
|
||||
t.hasStrict(await convert({ score: 900_000, error: 0 }), {
|
||||
dryScore: { scoreData: { lamp: "CONNECT ALL" } },
|
||||
});
|
||||
t.hasStrict(await convert({ score: 800_000, error: 10 }), {
|
||||
dryScore: { scoreData: { lamp: "CLEAR" } },
|
||||
});
|
||||
t.hasStrict(await convert({ score: 700_000, error: 10 }), {
|
||||
dryScore: { scoreData: { lamp: "FAILED" } },
|
||||
});
|
||||
t.hasStrict(await convert({ score: 799_999, error: 10 }), {
|
||||
dryScore: { scoreData: { lamp: "FAILED" } },
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -0,0 +1,104 @@
|
||||
import { ConverterAPICGSDVX } from "./converter";
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import t from "tap";
|
||||
import { dmf } from "test-utils/misc";
|
||||
import type { CGContext, CGSDVXScore } from "../types";
|
||||
import type { DryScore } from "lib/score-import/framework/common/types";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
function mkInput(modifant: Partial<CGSDVXScore> = {}) {
|
||||
const validInput: CGSDVXScore = {
|
||||
internalId: 1, // ALBIDA (Remix) ADV
|
||||
difficulty: 1,
|
||||
dateTime: "2019-06-06 08:14:22",
|
||||
score: 9_123_000,
|
||||
version: 6,
|
||||
clearType: 2,
|
||||
critical: 100,
|
||||
near: 50,
|
||||
error: 10,
|
||||
exScore: 1234,
|
||||
maxChain: 300,
|
||||
scoreGrade: "whatever, this is unused",
|
||||
};
|
||||
|
||||
return dmf(validInput, modifant);
|
||||
}
|
||||
|
||||
// we use any here because it's not easy to allow deep partials
|
||||
function mkOutput(modifant: any = {}): DryScore<"sdvx:Single"> {
|
||||
const validOutput: DryScore<"sdvx:Single"> = {
|
||||
comment: null,
|
||||
game: "sdvx",
|
||||
importType: "api/cg-dev-sdvx",
|
||||
timeAchieved: 1559805262000,
|
||||
service: "dev",
|
||||
scoreData: {
|
||||
grade: "A+",
|
||||
percent: 91.23,
|
||||
score: 9_123_000,
|
||||
lamp: "EXCESSIVE CLEAR",
|
||||
judgements: {
|
||||
critical: 100,
|
||||
near: 50,
|
||||
miss: 10,
|
||||
},
|
||||
hitMeta: {},
|
||||
},
|
||||
scoreMeta: {},
|
||||
};
|
||||
|
||||
return dmf(validOutput, modifant);
|
||||
}
|
||||
|
||||
t.test("#ConverterAPICGSDVX", (t) => {
|
||||
const context: CGContext = {
|
||||
service: "dev",
|
||||
userID: 1,
|
||||
};
|
||||
|
||||
const convert = (modifant: Partial<CGSDVXScore> = {}) =>
|
||||
ConverterAPICGSDVX(mkInput(modifant), context, "api/cg-dev-sdvx", logger);
|
||||
|
||||
t.test("Valid Input", async (t) => {
|
||||
const res = await convert();
|
||||
|
||||
t.hasStrict(res, {
|
||||
song: {
|
||||
id: 1,
|
||||
},
|
||||
chart: {
|
||||
difficulty: "ADV",
|
||||
data: {
|
||||
inGameID: 1,
|
||||
},
|
||||
},
|
||||
dryScore: mkOutput(),
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Lamps", async (t) => {
|
||||
t.hasStrict(await convert({ clearType: 0 }), {
|
||||
dryScore: mkOutput({ scoreData: { lamp: "FAILED" } }),
|
||||
});
|
||||
t.hasStrict(await convert({ clearType: 1 }), {
|
||||
dryScore: mkOutput({ scoreData: { lamp: "CLEAR" } }),
|
||||
});
|
||||
t.hasStrict(await convert({ clearType: 2 }), {
|
||||
dryScore: mkOutput({ scoreData: { lamp: "EXCESSIVE CLEAR" } }),
|
||||
});
|
||||
t.hasStrict(await convert({ clearType: 3 }), {
|
||||
dryScore: mkOutput({ scoreData: { lamp: "ULTIMATE CHAIN" } }),
|
||||
});
|
||||
t.hasStrict(await convert({ clearType: 4 }), {
|
||||
dryScore: mkOutput({ scoreData: { lamp: "PERFECT ULTIMATE CHAIN" } }),
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"chartID": "70b80da02a2037d556026b412c386b2fd1e57dbd",
|
||||
"data": {
|
||||
"inGameID": 1
|
||||
},
|
||||
"difficulty": "Green",
|
||||
"isPrimary": true,
|
||||
"level": "3",
|
||||
"levelNum": 3,
|
||||
"playtype": "Single",
|
||||
"rgcID": null,
|
||||
"songID": 1,
|
||||
"tierlistInfo": {},
|
||||
"versions": [
|
||||
"1.5",
|
||||
"1.5-b"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"altTitles": [],
|
||||
"artist": "Last Note. feat. GUMI",
|
||||
"data": {
|
||||
"artistJP": "ラストノートフィーチャリンググミ",
|
||||
"displayVersion": "1",
|
||||
"titleJP": "セツナトリップ"
|
||||
},
|
||||
"id": 1,
|
||||
"searchTerms": [],
|
||||
"title": "セツナトリップ"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user