Fix bug in remove, improve tests.

This commit is contained in:
Nicolás Venturo
2020-01-24 12:21:33 -03:00
parent 35e2af5a30
commit 305d714ca7
3 changed files with 53 additions and 18 deletions

View File

@ -64,26 +64,45 @@ describe('EnumerableSet', function () {
it('adds and removes multiple values', async function () {
// []
await this.set.add(accountA);
await this.set.add(accountC);
// [A, C]
await this.set.remove(accountA);
await this.set.remove(accountB);
// [C]
await this.set.add(accountB);
// [C, B]
await this.set.add(accountA);
await this.set.remove(accountC);
// [A, B]
expect(await this.set.contains(accountA)).to.equal(true);
expect(await this.set.contains(accountB)).to.equal(true);
expect(await this.set.contains(accountC)).to.equal(false);
await this.set.add(accountA);
await this.set.add(accountB);
expect(await this.set.enumerate()).to.have.same.members([ accountA, accountB ]);
// [A, B]
await this.set.add(accountC);
await this.set.remove(accountA);
// [B, C]
await this.set.add(accountA);
await this.set.remove(accountB);
// [A, C]
expect(await this.set.contains(accountA)).to.equal(true);
expect(await this.set.contains(accountB)).to.equal(false);
expect(await this.set.contains(accountC)).to.equal(true);
expect(await this.set.enumerate()).to.have.same.members([ accountA, accountC ]);
});
});