Skip to content

Commit

Permalink
feat(getIndex): Support Numerical id
Browse files Browse the repository at this point in the history
  • Loading branch information
Belphemur committed Mar 7, 2021
1 parent 7078323 commit d2e88ea
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/04-array-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ describe('Array Utils', () => {
expect(db.getIndex("/recipes", "78687873783", "test")).toBe(1);
expect(db.getIndex("/recipes", "12335373873", "test")).toBe(2);
})
test('should get the index of the current value with anything but numerical', () => {
const recipe_1 = {test: 65464646155, name: "Cheesecake", category: "Dessert"};
const recipe_2 = {test: 78687873783, name: "Gratin", category: "Dish"};
const recipe_3 = {test: 12335373873, name: "Soupe", category: "Starter"};
db.push("/recipes[0]", recipe_1, true);
db.push("/recipes[1]", recipe_2, true);
db.push("/recipes[2]", recipe_3, true);

expect(db.getIndex("/recipes", 65464646155, "test")).toBe(0);
expect(db.getIndex("/recipes", 78687873783, "test")).toBe(1);
expect(db.getIndex("/recipes", 12335373873, "test")).toBe(2);
})

})
describe('Cleanup', () => {
Expand Down

0 comments on commit d2e88ea

Please sign in to comment.