Skip to content

Commit

Permalink
test: .{at,keyAt}() indices
Browse files Browse the repository at this point in the history
  • Loading branch information
Renegade334 committed Oct 11, 2024
1 parent f4d9322 commit f4e3299
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/collection/__tests__/collection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,20 @@ describe('at() tests', () => {
expect(coll.at(0)).toStrictEqual(1);
});

test('positive non-integer index', () => {
expect(coll.at(1.5)).toStrictEqual(2);
});

test('negative index', () => {
expect(coll.at(-1)).toStrictEqual(3);
});

test('negative non-integer index', () => {
expect(coll.at(-2.5)).toStrictEqual(2);
});

test('invalid positive index', () => {
expect(coll.at(4)).toBeUndefined();
expect(coll.at(3)).toBeUndefined();
});

test('invalid negative index', () => {
Expand Down Expand Up @@ -432,12 +440,20 @@ describe('keyAt() tests', () => {
expect(coll.keyAt(0)).toStrictEqual('a');
});

test('positive non-integer index', () => {
expect(coll.keyAt(1.5)).toStrictEqual('b');
});

test('negative index', () => {
expect(coll.keyAt(-1)).toStrictEqual('c');
});

test('negative non-integer index', () => {
expect(coll.keyAt(-2.5)).toStrictEqual('b');
});

test('invalid positive index', () => {
expect(coll.keyAt(4)).toBeUndefined();
expect(coll.keyAt(3)).toBeUndefined();
});

test('invalid negative index', () => {
Expand Down

0 comments on commit f4e3299

Please sign in to comment.