Skip to content

Commit

Permalink
fix: increment test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsad committed Oct 9, 2023
1 parent c71b446 commit 33a7e93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/JsonDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,6 @@ export class JsonDB {
const pathValue = pathObject[pathKey]
try {
const pathIndex = await this.getIndex(normalPath.join(""), pathValue)
if(pathIndex === -1){
throw new DataError(`DataPath: ${normalPath.join("")}/${pathValue} not found.`, 13)
}
normalPath.push(`[${pathIndex}]`)
} catch (error) {
throw new DataError(`DataPath: ${normalPath.join("")}/${pathValue} not found.`, 13, error)
Expand Down
7 changes: 4 additions & 3 deletions test/JsonDB.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,19 @@ describe('JsonDB', () => {
})

describe('toPath()', () => {
test('should throw path error when path not found', () => {
test('should throw path error when not found item',() => {
db.getData = jest.fn(async () => ({
a: [
{
id: '1'
}
]
}))

expect(async () => {
await db.toPath('/a/2')
await db.toPath('/a/1')
}).rejects.toThrow(
'DataPath: /a/2 not found.'
'DataPath: /a/1 not found.'
)
})
})
Expand Down

0 comments on commit 33a7e93

Please sign in to comment.