Skip to content

Commit 752429e

Browse files
committed
refactor(#920): Update the method names
Update the stats and version methods names as explained. Fixes #920
1 parent 35b6241 commit 752429e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/lib/meilisearch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ class MeiliSearch {
182182
/**
183183
* Get the stats of all the database
184184
* @memberof MeiliSearch
185-
* @method stats
185+
* @method getStats
186186
*/
187-
async stats(): Promise<Stats> {
187+
async getStats(): Promise<Stats> {
188188
const url = `stats`
189189
return await this.httpRequest.get<Stats>(url)
190190
}
@@ -196,9 +196,9 @@ class MeiliSearch {
196196
/**
197197
* Get the version of MeiliSearch
198198
* @memberof MeiliSearch
199-
* @method version
199+
* @method getVersion
200200
*/
201-
async version(): Promise<Version> {
201+
async getVersion(): Promise<Version> {
202202
const url = `version`
203203
return await this.httpRequest.get<Version>(url)
204204
}

tests/client_tests.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,15 +357,15 @@ describe.each([
357357
})
358358

359359
test(`${permission} key: get version`, async () => {
360-
await client.version().then((response: Version) => {
360+
await client.getVersion().then((response: Version) => {
361361
expect(response).toHaveProperty('commitSha', expect.any(String))
362362
expect(response).toHaveProperty('commitDate', expect.any(String))
363363
expect(response).toHaveProperty('pkgVersion', expect.any(String))
364364
})
365365
})
366366

367367
test(`${permission} key: get /stats information`, async () => {
368-
await client.stats().then((response: Stats) => {
368+
await client.getStats().then((response: Stats) => {
369369
expect(response).toHaveProperty('databaseSize', expect.any(Number))
370370
expect(response).toHaveProperty('lastUpdate') // TODO: Could be null, find out why
371371
expect(response).toHaveProperty('indexes', expect.any(Object))
@@ -432,14 +432,14 @@ describe.each([{ client: publicClient, permission: 'Public' }])(
432432
})
433433

434434
test(`${permission} key: try to get version and be denied`, async () => {
435-
await expect(client.version()).rejects.toHaveProperty(
435+
await expect(client.getVersion()).rejects.toHaveProperty(
436436
'errorCode',
437437
ErrorStatusCode.INVALID_TOKEN
438438
)
439439
})
440440

441441
test(`${permission} key: try to get /stats information and be denied`, async () => {
442-
await expect(client.stats()).rejects.toHaveProperty(
442+
await expect(client.getStats()).rejects.toHaveProperty(
443443
'errorCode',
444444
ErrorStatusCode.INVALID_TOKEN
445445
)
@@ -525,14 +525,14 @@ describe.each([{ client: anonymousClient, permission: 'No' }])(
525525
})
526526

527527
test(`${permission} key: try to get version and be denied`, async () => {
528-
await expect(client.version()).rejects.toHaveProperty(
528+
await expect(client.getVersion()).rejects.toHaveProperty(
529529
'errorCode',
530530
ErrorStatusCode.MISSING_AUTHORIZATION_HEADER
531531
)
532532
})
533533

534534
test(`${permission} key: try to get /stats information and be denied`, async () => {
535-
await expect(client.stats()).rejects.toHaveProperty(
535+
await expect(client.getStats()).rejects.toHaveProperty(
536536
'errorCode',
537537
ErrorStatusCode.MISSING_AUTHORIZATION_HEADER
538538
)
@@ -655,7 +655,7 @@ describe.each([
655655
const route = `stats`
656656
const client = new MeiliSearch({ host })
657657
const strippedHost = trailing ? host.slice(0, -1) : host
658-
await expect(client.stats()).rejects.toHaveProperty(
658+
await expect(client.getStats()).rejects.toHaveProperty(
659659
'message',
660660
`request to ${strippedHost}/${route} failed, reason: connect ECONNREFUSED ${BAD_HOST.replace(
661661
'http://',
@@ -668,7 +668,7 @@ describe.each([
668668
const route = `version`
669669
const client = new MeiliSearch({ host })
670670
const strippedHost = trailing ? host.slice(0, -1) : host
671-
await expect(client.version()).rejects.toHaveProperty(
671+
await expect(client.getVersion()).rejects.toHaveProperty(
672672
'message',
673673
`request to ${strippedHost}/${route} failed, reason: connect ECONNREFUSED ${BAD_HOST.replace(
674674
'http://',

0 commit comments

Comments
 (0)