Skip to content

Commit 889d55e

Browse files
committed
feat: change method name
1 parent 6a95687 commit 889d55e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/JsonDB.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ export class JsonDB {
421421
* @param path router based path to a correct base path
422422
* @param propertyName name of the property to look for searchValue
423423
*/
424-
public async toPath(path: string, propertyName:string = 'id' ): Promise<string> {
424+
public async fromPath(path: string, propertyName:string = 'id' ): Promise<string> {
425425

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

test/04-array-utils.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ describe('Array Utils', () => {
249249

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

252-
const normalPath = await db.toPath(routerPathStyle)
252+
const normalPath = await db.fromPath(routerPathStyle)
253253

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

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

292-
const normalPath = await db.toPath(routerPathStyle, '_id')
292+
const normalPath = await db.fromPath(routerPathStyle, '_id')
293293

294294
expect(normalPath).toEqual('/recipes[1]/nested[1]')
295295
})

test/JsonDB.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe('JsonDB', () => {
9696
})
9797
})
9898

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

109109
expect(async () => {
110-
await db.toPath('/a/1')
110+
await db.fromPath('/a/1')
111111
}).rejects.toThrow(
112112
'DataPath: /a/1 not found.'
113113
)
@@ -122,7 +122,7 @@ describe('JsonDB', () => {
122122
}))
123123

124124
expect(async () => {
125-
await db.toPath('/a/1', '_id')
125+
await db.fromPath('/a/1', '_id')
126126
}).rejects.toThrow(
127127
'DataPath: /a/1 not found.'
128128
)

0 commit comments

Comments
 (0)