mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-02 03:48:14 +03:00
Merge pull request #94 from zkldi:zkldi/issue93
file/mer-iidx More Parser Tests
This commit is contained in:
Generated
+3
-3
@@ -62,7 +62,7 @@ dependencies:
|
||||
express-session: 1.17.1
|
||||
fast-json-stable-hash: 1.0.2
|
||||
fast-xml-parser: 3.19.0
|
||||
kamaitachi-common: github.com/zkldi/Kamaitachi-common/945bbea5c20656b1428461207b430b2a130b2c28
|
||||
kamaitachi-common: github.com/zkldi/Kamaitachi-common/31a5120bbeadbd7c1b294b84ac9ca228f428114b
|
||||
mongodb: 3.6.6
|
||||
monk: 7.3.4
|
||||
multer: 1.4.2
|
||||
@@ -4644,8 +4644,8 @@ packages:
|
||||
'@types/yoga-layout': 1.9.2
|
||||
dev: true
|
||||
|
||||
github.com/zkldi/Kamaitachi-common/945bbea5c20656b1428461207b430b2a130b2c28:
|
||||
resolution: {tarball: https://codeload.github.com/zkldi/Kamaitachi-common/tar.gz/945bbea5c20656b1428461207b430b2a130b2c28}
|
||||
github.com/zkldi/Kamaitachi-common/31a5120bbeadbd7c1b294b84ac9ca228f428114b:
|
||||
resolution: {tarball: https://codeload.github.com/zkldi/Kamaitachi-common/tar.gz/31a5120bbeadbd7c1b294b84ac9ca228f428114b}
|
||||
name: kamaitachi-common
|
||||
version: 0.1.0
|
||||
dependencies:
|
||||
|
||||
@@ -4,8 +4,9 @@ import { CloseMongoConnection } from "../../../../db/db";
|
||||
import CreateLogCtx from "../../../../logger";
|
||||
import { MockMulterFile } from "../../../../test-utils/mock-multer";
|
||||
import ResetDBState from "../../../../test-utils/reset-db-state";
|
||||
import { GetKTDataBuffer } from "../../../../test-utils/test-data";
|
||||
import { GetKTDataBuffer, GetKTDataJSON } from "../../../../test-utils/test-data";
|
||||
import { ParseMerIIDX } from "./parser";
|
||||
import deepmerge from "deepmerge";
|
||||
|
||||
const logger = CreateLogCtx("parser.test.ts");
|
||||
|
||||
@@ -16,6 +17,14 @@ t.test("#ParseMerIIDX", (t) => {
|
||||
return ParseMerIIDX(MockMulterFile(buffer, "buffer.json"), {}, logger);
|
||||
}
|
||||
|
||||
function mrfj(obj: any) {
|
||||
return ParseMerIIDX(
|
||||
MockMulterFile(Buffer.from(JSON.stringify(obj)), "buffer.json"),
|
||||
{},
|
||||
logger
|
||||
);
|
||||
}
|
||||
|
||||
function mrff(filename: string) {
|
||||
return ParseMerIIDX(MockMulterFile(GetKTDataBuffer(filename), filename), {}, logger);
|
||||
}
|
||||
@@ -70,6 +79,51 @@ t.test("#ParseMerIIDX", (t) => {
|
||||
t.end();
|
||||
});
|
||||
|
||||
const baseScore = GetKTDataJSON("./mer/base.json");
|
||||
|
||||
t.test("Should throw on invalid play_type", (t) => {
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { play_type: "INVALID" })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { play_type: null })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { play_type: undefined })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { play_type: 1 })));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Should throw on invalid score", (t) => {
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { score: -1 })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { score: 1.5 })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { score: "1" })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { score: null })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { score: undefined })));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Should throw on invalid diff_type", (t) => {
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { diff_type: "INVALID" })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { diff_type: null })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { diff_type: undefined })));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Should throw on invalid clear_type", (t) => {
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { clear_type: "INVALID" })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { clear_type: null })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { clear_type: undefined })));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Should throw on invalid miss_count", (t) => {
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { miss_count: "INVALID" })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { miss_count: null })));
|
||||
t.throws(() => mrfj(deepmerge(baseScore, { miss_count: undefined })));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Should throw on invalid JSON", (t) => {
|
||||
t.throws(() => mrfb(Buffer.from("{]")));
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ const baseDryScore = {
|
||||
gaugeHistory: [100, 50],
|
||||
gauge: 50,
|
||||
bp: 6,
|
||||
comboBreak: null,
|
||||
comboBreak: 6,
|
||||
gsm: undefined,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -156,7 +156,7 @@ export const ConverterIRFervidex: ConverterFunction<FervidexScore, FervidexConte
|
||||
|
||||
if (!chart) {
|
||||
throw new KTDataNotFoundFailure(
|
||||
`Could not find chart with songID ${data.entry_id} (${playtype} ${difficulty})`,
|
||||
`Could not find chart with songID ${data.entry_id} (${playtype} ${difficulty} [${context.version}])`,
|
||||
importType,
|
||||
data,
|
||||
context
|
||||
|
||||
@@ -8,13 +8,17 @@
|
||||
"playtype": "SP",
|
||||
"songID": 1,
|
||||
"flags": {
|
||||
"2dxtra": false,
|
||||
"IN BASE GAME": true,
|
||||
"OMNIMIX": true,
|
||||
"N-1": true
|
||||
},
|
||||
"data": {
|
||||
"notecount": 786,
|
||||
"inGameID": 1000
|
||||
"inGameID": 1000,
|
||||
"hashSHA256": null,
|
||||
"arcChartID": null,
|
||||
"2dxtraSet": null
|
||||
},
|
||||
"isPrimary": true,
|
||||
"versions": ["0",
|
||||
|
||||
Reference in New Issue
Block a user