From 6a95687ea3528ba455a19ee3e64417a4edc099f8 Mon Sep 17 00:00:00 2001 From: alexsad Date: Mon, 16 Oct 2023 13:08:29 -0300 Subject: [PATCH] feat: test wrong propertyName --- test/JsonDB.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/JsonDB.test.ts b/test/JsonDB.test.ts index 6d80287c..c01adea4 100644 --- a/test/JsonDB.test.ts +++ b/test/JsonDB.test.ts @@ -112,6 +112,21 @@ describe('JsonDB', () => { 'DataPath: /a/1 not found.' ) }) + test('should throw path error when not found item and using a wrong propertyName',() => { + db.getData = jest.fn(async () => ({ + a: [ + { + id: '1' + } + ] + })) + + expect(async () => { + await db.toPath('/a/1', '_id') + }).rejects.toThrow( + 'DataPath: /a/1 not found.' + ) + }) }) // Test was made for code coverage for getParentData, but this cannot return null or undefined.