test: add promotion test

main
spacemeowx2 2022-10-31 13:31:30 +08:00
parent 2e748adcf4
commit dc69b3dc5c
2 changed files with 109 additions and 10 deletions

View File

@ -46,8 +46,6 @@ function genOpenWins(
bankaraMatch: {
earnedUdemaePoint: 8,
},
nextHistoryDetail: null,
previousHistoryDetail: null,
});
id += 1;
}
@ -55,6 +53,115 @@ function genOpenWins(
return result;
}
Deno.test("RankTracker tracks promotion, ignoring INPROGRESS", async () => {
const INIT_STATE = {
gameId: await gameId(genId(0)),
rank: "B+",
rankPoint: 850,
};
const tracker = new TestRankTracker(INIT_STATE);
assertEquals(tracker.testGet(), {
state: INIT_STATE,
deltaMap: new Map(),
});
const finalState = await tracker.updateState([{
bankaraMatchChallenge: {
winCount: 2,
loseCount: 0,
maxWinCount: 3,
maxLoseCount: 3,
state: "INPROGRESS",
isPromo: true,
isUdemaeUp: true,
udemaeAfter: "A-",
earnedUdemaePoint: null,
},
historyDetails: {
nodes: [{
id: await genId(1),
udemae: "B+",
judgement: "WIN",
bankaraMatch: {
earnedUdemaePoint: null,
},
}, {
id: await genId(0),
udemae: "B+",
judgement: "WIN",
bankaraMatch: {
earnedUdemaePoint: null,
},
}],
},
}]);
assertEquals(finalState, {
gameId: await gameId(genId(1)),
rank: "B+",
rankPoint: 850,
});
});
Deno.test("RankTracker tracks promotion", async () => {
const INIT_STATE = {
gameId: await gameId(genId(0)),
rank: "B+",
rankPoint: 850,
};
const tracker = new TestRankTracker(INIT_STATE);
assertEquals(tracker.testGet(), {
state: INIT_STATE,
deltaMap: new Map(),
});
const finalState = await tracker.updateState([{
bankaraMatchChallenge: {
winCount: 3,
loseCount: 0,
maxWinCount: 3,
maxLoseCount: 3,
state: "SUCCEEDED",
isPromo: true,
isUdemaeUp: true,
udemaeAfter: "A-",
earnedUdemaePoint: null,
},
historyDetails: {
nodes: [{
id: await genId(2),
udemae: "B+",
judgement: "WIN",
bankaraMatch: {
earnedUdemaePoint: null,
},
}, {
id: await genId(1),
udemae: "B+",
judgement: "WIN",
bankaraMatch: {
earnedUdemaePoint: null,
},
}, {
id: await genId(0),
udemae: "B+",
judgement: "WIN",
bankaraMatch: {
earnedUdemaePoint: null,
},
}],
},
}]);
assertEquals(finalState, {
gameId: await gameId(genId(2)),
rank: "A-",
rankPoint: 200,
});
});
Deno.test("RankTracker tracks challenge charge", async () => {
const tracker = new TestRankTracker(INIT_STATE);
assertEquals(tracker.testGet(), {
@ -83,8 +190,6 @@ Deno.test("RankTracker tracks challenge charge", async () => {
bankaraMatch: {
earnedUdemaePoint: null,
},
nextHistoryDetail: null,
previousHistoryDetail: null,
},
],
},

View File

@ -45,12 +45,6 @@ export type BattleListNode = {
id: string;
udemae: string;
judgement: "LOSE" | "WIN" | "DEEMED_LOSE" | "EXEMPTED_LOSE" | "DRAW";
nextHistoryDetail: null | {
id: string;
};
previousHistoryDetail: null | {
id: string;
};
bankaraMatch: null | {
earnedUdemaePoint: null | number;
};