Skip to content

Commit 166db78

Browse files
Merge #1016
1016: refactor(#920): Update the method names r=bidoubiwa a=TheLearneer Update the stats and version methods names as explained. Fixes #920 Co-authored-by: Santosh Bhandari <[email protected]>
2 parents 6cd2c17 + 304c4f0 commit 166db78

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,13 @@ Or using the index object:
549549

550550
- Get database stats
551551

552-
`client.stats(): Promise<Stats>`
552+
`client.getStats(): Promise<Stats>`
553553

554554
### Version <!-- omit in toc -->
555555

556556
- Get binary version
557557

558-
`client.version(): Promise<Version>`
558+
`client.getVersion(): Promise<Version>`
559559

560560
### Dumps <!-- omit in toc -->
561561

src/lib/meilisearch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ class MeiliSearch {
188188
/**
189189
* Get the stats of all the database
190190
* @memberof MeiliSearch
191-
* @method stats
191+
* @method getStats
192192
*/
193-
async stats(): Promise<Stats> {
193+
async getStats(): Promise<Stats> {
194194
const url = `stats`
195195
return await this.httpRequest.get<Stats>(url)
196196
}
@@ -202,9 +202,9 @@ class MeiliSearch {
202202
/**
203203
* Get the version of MeiliSearch
204204
* @memberof MeiliSearch
205-
* @method version
205+
* @method getVersion
206206
*/
207-
async version(): Promise<Version> {
207+
async getVersion(): Promise<Version> {
208208
const url = `version`
209209
return await this.httpRequest.get<Version>(url)
210210
}

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)