Skip to content

Commit 6a8ee73

Browse files
committed
feat(getIndex): Support Numerical id
1 parent 7a94172 commit 6a8ee73

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/04-array-utils.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ describe('Array Utils', () => {
4747
expect(db.getIndex("/recipes", "78687873783", "test")).toBe(1);
4848
expect(db.getIndex("/recipes", "12335373873", "test")).toBe(2);
4949
})
50+
test('should get the index of the current value with anything but numerical', () => {
51+
const recipe_1 = {test: 65464646155, name: "Cheesecake", category: "Dessert"};
52+
const recipe_2 = {test: 78687873783, name: "Gratin", category: "Dish"};
53+
const recipe_3 = {test: 12335373873, name: "Soupe", category: "Starter"};
54+
db.push("/recipes[0]", recipe_1, true);
55+
db.push("/recipes[1]", recipe_2, true);
56+
db.push("/recipes[2]", recipe_3, true);
57+
58+
expect(db.getIndex("/recipes", 65464646155, "test")).toBe(0);
59+
expect(db.getIndex("/recipes", 78687873783, "test")).toBe(1);
60+
expect(db.getIndex("/recipes", 12335373873, "test")).toBe(2);
61+
})
5062

5163
})
5264
describe('Cleanup', () => {

0 commit comments

Comments
 (0)