Skip to content

Commit f674279

Browse files
committed
expand set tests
1 parent 615d0f9 commit f674279

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/data/EnumerableMap.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,24 @@ describe('EnumerableMap', () => {
122122
);
123123
});
124124

125+
it('does not increase length if overwriting value at already set key', async () => {
126+
await instance['set(address,address)'](addressOne, addressThree);
127+
expect(await instance.callStatic['length()']()).to.eq(1);
128+
await instance['set(address,address)'](addressOne, addressTwo);
129+
expect(await instance.callStatic['length()']()).to.eq(1);
130+
});
131+
132+
it('overwrites value if key already set', async () => {
133+
await instance['set(address,address)'](addressOne, addressThree);
134+
let [key, value] = await instance.callStatic['at(uint256)'](0);
135+
expect(key).to.eq(addressOne);
136+
expect(value).to.eq(addressThree);
137+
await instance['set(address,address)'](addressOne, addressFour);
138+
[key, value] = await instance.callStatic['at(uint256)'](0);
139+
expect(key).to.eq(addressOne);
140+
expect(value).to.eq(addressFour);
141+
});
142+
125143
it('returns true if address value is added at address key', async () => {
126144
expect(
127145
await instance.callStatic['set(address,address)'](
@@ -283,6 +301,24 @@ describe('EnumerableMap', () => {
283301
);
284302
});
285303

304+
it('does not increase length if overwriting value at already set key', async () => {
305+
await instance['set(uint256,address)'](uintOne, addressThree);
306+
expect(await instance.callStatic['length()']()).to.eq(1);
307+
await instance['set(uint256,address)'](uintOne, addressTwo);
308+
expect(await instance.callStatic['length()']()).to.eq(1);
309+
});
310+
311+
it('overwrites value if key already set', async () => {
312+
await instance['set(uint256,address)'](uintOne, addressThree);
313+
let [key, value] = await instance.callStatic['at(uint256)'](0);
314+
expect(key).to.eq(uintOne);
315+
expect(value).to.eq(addressThree);
316+
await instance['set(uint256,address)'](uintOne, addressTwo);
317+
[key, value] = await instance.callStatic['at(uint256)'](0);
318+
expect(key).to.eq(uintOne);
319+
expect(value).to.eq(addressTwo);
320+
});
321+
286322
it('returns true if address value is added at uint256 key', async () => {
287323
expect(
288324
await instance.callStatic['set(uint256,address)'](

0 commit comments

Comments
 (0)