test: add promotion test
parent
2e748adcf4
commit
dc69b3dc5c
|
|
@ -46,8 +46,6 @@ function genOpenWins(
|
||||||
bankaraMatch: {
|
bankaraMatch: {
|
||||||
earnedUdemaePoint: 8,
|
earnedUdemaePoint: 8,
|
||||||
},
|
},
|
||||||
nextHistoryDetail: null,
|
|
||||||
previousHistoryDetail: null,
|
|
||||||
});
|
});
|
||||||
id += 1;
|
id += 1;
|
||||||
}
|
}
|
||||||
|
|
@ -55,6 +53,115 @@ function genOpenWins(
|
||||||
return result;
|
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 () => {
|
Deno.test("RankTracker tracks challenge charge", async () => {
|
||||||
const tracker = new TestRankTracker(INIT_STATE);
|
const tracker = new TestRankTracker(INIT_STATE);
|
||||||
assertEquals(tracker.testGet(), {
|
assertEquals(tracker.testGet(), {
|
||||||
|
|
@ -83,8 +190,6 @@ Deno.test("RankTracker tracks challenge charge", async () => {
|
||||||
bankaraMatch: {
|
bankaraMatch: {
|
||||||
earnedUdemaePoint: null,
|
earnedUdemaePoint: null,
|
||||||
},
|
},
|
||||||
nextHistoryDetail: null,
|
|
||||||
previousHistoryDetail: null,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,6 @@ export type BattleListNode = {
|
||||||
id: string;
|
id: string;
|
||||||
udemae: string;
|
udemae: string;
|
||||||
judgement: "LOSE" | "WIN" | "DEEMED_LOSE" | "EXEMPTED_LOSE" | "DRAW";
|
judgement: "LOSE" | "WIN" | "DEEMED_LOSE" | "EXEMPTED_LOSE" | "DRAW";
|
||||||
nextHistoryDetail: null | {
|
|
||||||
id: string;
|
|
||||||
};
|
|
||||||
previousHistoryDetail: null | {
|
|
||||||
id: string;
|
|
||||||
};
|
|
||||||
bankaraMatch: null | {
|
bankaraMatch: null | {
|
||||||
earnedUdemaePoint: null | number;
|
earnedUdemaePoint: null | number;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue