test: fix RankTracker

main
spacemeowx2 2022-12-01 16:21:16 +08:00 committed by imspace
parent db636756e3
commit c2e9e623ac
2 changed files with 13 additions and 0 deletions

View File

@ -61,6 +61,7 @@ Deno.test("RankTracker don't promo after failed challenge", async () => {
});
const finalState = await tracker.updateState([{
xMatchMeasurement: null,
bankaraMatchChallenge: {
winCount: 0,
loseCount: 3,
@ -102,6 +103,7 @@ Deno.test("RankTracker autotrack after promotion", async () => {
});
const finalState = await tracker.updateState([{
xMatchMeasurement: null,
bankaraMatchChallenge: {
winCount: 3,
loseCount: 0,
@ -161,6 +163,7 @@ Deno.test("RankTracker issue #36", async () => {
});
const finalState = await tracker.updateState([{
xMatchMeasurement: null,
bankaraMatchChallenge: {
winCount: 3,
loseCount: 0,
@ -228,6 +231,7 @@ Deno.test("RankTracker tracks promotion, ignoring INPROGRESS", async () => {
});
const finalState = await tracker.updateState([{
xMatchMeasurement: null,
bankaraMatchChallenge: {
winCount: 2,
loseCount: 0,
@ -279,6 +283,7 @@ Deno.test("RankTracker tracks promotion", async () => {
});
const finalState = await tracker.updateState([{
xMatchMeasurement: null,
bankaraMatchChallenge: {
winCount: 3,
loseCount: 0,
@ -331,6 +336,7 @@ Deno.test("RankTracker tracks challenge charge", async () => {
});
const finalState = await tracker.updateState([{
xMatchMeasurement: null,
bankaraMatchChallenge: {
winCount: 1,
loseCount: 0,
@ -355,6 +361,7 @@ Deno.test("RankTracker tracks challenge charge", async () => {
],
},
}, {
xMatchMeasurement: null,
bankaraMatchChallenge: null,
historyDetails: {
nodes: genOpenWins({
@ -382,6 +389,7 @@ Deno.test("RankTracker", async () => {
});
const finalState = await tracker.updateState([{
xMatchMeasurement: null,
bankaraMatchChallenge: null,
historyDetails: {
nodes: [...genOpenWins({
@ -418,6 +426,7 @@ Deno.test("RankTracker", async () => {
// history goes too far
const finalState2 = await tracker.updateState([{
xMatchMeasurement: null,
bankaraMatchChallenge: null,
historyDetails: {
nodes: [...genOpenWins({
@ -430,6 +439,7 @@ Deno.test("RankTracker", async () => {
assertEquals(finalState2, undefined);
await tracker.updateState([{
xMatchMeasurement: null,
bankaraMatchChallenge: null,
historyDetails: {
nodes: [...genOpenWins({

View File

@ -220,6 +220,9 @@ function generateDeltaList(
function getRankState(i: FlattenItem): RankState {
const rank = i.detail.udemae;
if (!rank) {
throw new Error("rank must be defined");
}
const param = RANK_PARAMS.find((i) => i.rank === rank);
if (!param) {