Skip to content

Commit

Permalink
feat: change method name
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsad committed Oct 16, 2023
1 parent 6a95687 commit 889d55e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/JsonDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ export class JsonDB {
* @param path router based path to a correct base path
* @param propertyName name of the property to look for searchValue
*/
public async toPath(path: string, propertyName:string = 'id' ): Promise<string> {
public async fromPath(path: string, propertyName:string = 'id' ): Promise<string> {

const [,...pathToQuery] = path.split("/")

Expand Down
4 changes: 2 additions & 2 deletions test/04-array-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe('Array Utils', () => {

const routerPathStyle = '/recipes/65464646155/nested/88488'

const normalPath = await db.toPath(routerPathStyle)
const normalPath = await db.fromPath(routerPathStyle)

expect(normalPath).toEqual('/recipes[1]/nested[1]')
})
Expand Down Expand Up @@ -289,7 +289,7 @@ describe('Array Utils', () => {

const routerPathStyle = '/recipes/65464646155/nested/88488'

const normalPath = await db.toPath(routerPathStyle, '_id')
const normalPath = await db.fromPath(routerPathStyle, '_id')

expect(normalPath).toEqual('/recipes[1]/nested[1]')
})
Expand Down
6 changes: 3 additions & 3 deletions test/JsonDB.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('JsonDB', () => {
})
})

describe('toPath()', () => {
describe('fromPath()', () => {
test('should throw path error when not found item',() => {
db.getData = jest.fn(async () => ({
a: [
Expand All @@ -107,7 +107,7 @@ describe('JsonDB', () => {
}))

expect(async () => {
await db.toPath('/a/1')
await db.fromPath('/a/1')
}).rejects.toThrow(
'DataPath: /a/1 not found.'
)
Expand All @@ -122,7 +122,7 @@ describe('JsonDB', () => {
}))

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

0 comments on commit 889d55e

Please sign in to comment.