mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-10 16:28:17 +03:00
refactor tests
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import t from "tap";
|
||||
import mockApi from "../../test-utils/mock-api";
|
||||
import {
|
||||
GetKTDataBuffer,
|
||||
GetKTDataJSON,
|
||||
TestingIIDXEamusementCSV26,
|
||||
TestingIIDXEamusementCSV27,
|
||||
@@ -13,11 +14,14 @@ import { rootLogger } from "../../logger";
|
||||
import { GetUnsuccessfulScores } from "../../test-utils/score-import-utils";
|
||||
import db from "../../db/db";
|
||||
|
||||
async function LoadKTBlackSongsIIDX() {
|
||||
let data = GetKTDataJSON("./kamaitachi/ktblack-songs-iidx.json");
|
||||
async function LoadKTBlackIIDXData() {
|
||||
let songs = GetKTDataJSON("./kamaitachi/ktblack-songs-iidx.json");
|
||||
let charts = GetKTDataJSON("./kamaitachi/ktblack-charts-iidx.json");
|
||||
|
||||
await db.songs.iidx.remove({});
|
||||
await db.songs.iidx.insert(data);
|
||||
await db.songs.iidx.insert(songs);
|
||||
await db.charts.iidx.remove({});
|
||||
await db.charts.iidx.insert(charts);
|
||||
}
|
||||
// reset DB handles the post-stuff
|
||||
|
||||
@@ -29,7 +33,32 @@ t.test("POST /internal-api/import/file", async (t) => {
|
||||
RequireNeutralAuthentication("/internal-api/import/file", "POST");
|
||||
|
||||
t.test("file/csv:eamusement-iidx", (t) => {
|
||||
t.beforeEach(LoadKTBlackSongsIIDX);
|
||||
t.beforeEach(LoadKTBlackIIDXData);
|
||||
|
||||
t.test("Mini HV import", async (t) => {
|
||||
let res = await mockApi
|
||||
.post("/internal-api/import/file")
|
||||
.set("Cookie", cookie)
|
||||
.attach(
|
||||
"scoreData",
|
||||
GetKTDataBuffer("./csv-eamusement-iidx/small-hv-file.csv"),
|
||||
"my_csv.csv"
|
||||
)
|
||||
.field("importType", "file/csv:eamusement-iidx")
|
||||
.field("playtype", "SP");
|
||||
|
||||
t.equal(res.body.success, true, "Should be successful.");
|
||||
|
||||
t.equal(
|
||||
GetUnsuccessfulScores(res.body.body),
|
||||
0,
|
||||
"Mini HV Import Should have 0 failed scores."
|
||||
);
|
||||
|
||||
t.equal(res.body.body.importInfo.length, 2, "Should have 2 successful scores.");
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Valid Rootage CSV import", async (t) => {
|
||||
let res = await mockApi
|
||||
@@ -46,7 +75,7 @@ t.test("POST /internal-api/import/file", async (t) => {
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Valid Heroic Verse CSV import", async (t) => {
|
||||
t.skip("Valid Heroic Verse CSV import", async (t) => {
|
||||
let res = await mockApi
|
||||
.post("/internal-api/import/file")
|
||||
.set("Cookie", cookie)
|
||||
|
||||
Reference in New Issue
Block a user