From ab22caad16364697c7c875e3edf70ee7318d5761 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Thu, 2 Dec 2021 10:20:26 +0000 Subject: [PATCH] Add tests for the new batch manual behaviour. --- .../common/batch-manual/converter.test.ts | 32 +++++++++++++++++++ .../common/batch-manual/parser.test.ts | 26 +++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/server/src/lib/score-import/import-types/common/batch-manual/converter.test.ts b/server/src/lib/score-import/import-types/common/batch-manual/converter.test.ts index ccd56acd1..99e1ae443 100644 --- a/server/src/lib/score-import/import-types/common/batch-manual/converter.test.ts +++ b/server/src/lib/score-import/import-types/common/batch-manual/converter.test.ts @@ -358,6 +358,38 @@ t.test("#ConverterFn", (t) => { t.end(); }); + t.test("Should produce a with timeAchieved null if timeAchieved is 0", async (t) => { + const res = await ConverterBatchManual( + deepmerge(baseBatchManualScore, { timeAchieved: 0 }), + { game: "iidx", service: "foo", playtype: "SP", version: null }, + importType, + logger + ); + + t.hasStrict(res, { + chart: Testing511SPA, + song: { id: 1 }, + dryScore: { + game: "iidx", + service: "foo (BATCH-MANUAL)", + comment: null, + importType: "file/batch-manual", + timeAchieved: null, + scoreData: { + lamp: "HARD CLEAR", + score: 500, + grade: "E", + // percent: 31.5, -- ish, FPA is hard. + judgements: {}, + hitMeta: {}, + }, + scoreMeta: {}, + }, + }); + + t.end(); + }); + t.test("Should reject a score with > 100%", (t) => { t.rejects( () => diff --git a/server/src/lib/score-import/import-types/common/batch-manual/parser.test.ts b/server/src/lib/score-import/import-types/common/batch-manual/parser.test.ts index 081fd25aa..f7ba128d8 100644 --- a/server/src/lib/score-import/import-types/common/batch-manual/parser.test.ts +++ b/server/src/lib/score-import/import-types/common/batch-manual/parser.test.ts @@ -402,6 +402,32 @@ t.test("#ParserFn", (t) => { t.end(); }); + t.test("TimeAchieved of 0 should be legal.", (t) => { + const res = ParserFn(dm({ timeAchieved: 0 }), "file/batch-manual", logger); + + t.hasStrict(res, { + game: "iidx", + context: { + service: "foo", + game: "iidx", + playtype: "SP", + version: null, + }, + iterable: [ + { + score: 1000, + lamp: "HARD CLEAR", + matchType: "tachiSongID", + identifier: "123", + difficulty: "ANOTHER", + timeAchieved: 0, + }, + ], + }); + + t.end(); + }); + t.test("Invalid Identifier", (t) => { // this is not a valid playtype for IIDX const fn = () => ParserFn(dm({ identifier: null }), "file/batch-manual", logger);