Skip to content

Commit

Permalink
Check shuffle keeps member status intact
Browse files Browse the repository at this point in the history
  • Loading branch information
jouni-kantola committed Apr 7, 2024
1 parent 70cc18e commit 53c7ce1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/team-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ test("only shrink by removing inactive members", () => {
assert.strictEqual(team.at(-1)!.index, 0);
});

test("shuffle team", () => {
test("shuffle team with status kept intact", () => {
const members = ["Member 1", "Member 2", "Member 3"];
const team = createTeam(members);
team[0].isActive = false;
team[1].isHere = false;
team[2].isActive = true;

shuffleTeam(team);

Expand All @@ -158,6 +161,18 @@ test("shuffle team", () => {
assert.strictEqual(team[0].index, 0);
assert.strictEqual(team[1].index, 1);
assert.strictEqual(team[2].index, 2);

const member1 = team.find(m => m.name === "Member 1")!;
assert.isFalse(member1.isActive);
assert.isTrue(member1.isHere);

const member2 = team.find(m => m.name === "Member 2")!;
assert.isFalse(member2.isHere);
assert.isFalse(member2.isActive);

const member3 = team.find(m => m.name === "Member 3")!;
assert.isTrue(member3.isActive);
assert.isTrue(member3.isHere);
});

test("shuffle team of one stays same", () => {
Expand Down

0 comments on commit 53c7ce1

Please sign in to comment.