Skip to content

Commit

Permalink
Remove acceptNewFields and update tests accordingly (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
bidoubiwa authored Jul 28, 2020
1 parent 7872423 commit 57e5c52
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 205 deletions.
11 changes: 1 addition & 10 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ update_settings_1: |-
synonyms: {
'wolverine': ['xmen', 'logan'],
'logan': ['wolverine']
},
acceptNewFields: false
}
})
reset_settings_1: |-
client.getIndex('movies').resetSettings()
Expand Down Expand Up @@ -148,10 +147,6 @@ update_displayed_attributes_1: |-
])
reset_displayed_attributes_1: |-
client.getIndex('movies').resetDisplayedAttributes()
get_accept_new_fields_1: |-
client.getIndex('movies').getAcceptNewFields()
update_accept_new_fields_1: |-
client.getIndex('movies').updateAcceptNewFields(false)
get_index_stats_1: |-
client.getIndex('movies').getStats()
get_indexes_stats_1: |-
Expand Down Expand Up @@ -295,10 +290,6 @@ settings_guide_displayed_1: |-
'rank'
]
})
settings_guide_accept_new_fields_1: |-
client.getIndex('movies').settings({
acceptNewFields: false
})
add_movies_json_1: |-
const movies = require('./movies.json')
index.addDocuments(movies).then((res) => console.log(res))
Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,6 @@ If you want to know more about the development workflow or want to contribute, p
- Reset Displayed Attributes
`index.resetDisplayedAttributes(): Promise<EnqueuedUpdate>`

### Accept new fields <!-- omit in toc -->

- Get Accept new fields
`index.getAcceptNewFields(): Promise<boolean>`

- Update Accept new fields
`index.updateAcceptNewFields(acceptNewFields: boolean): Promise<EnqueuedUpdate>`

### Keys <!-- omit in toc -->

- Get keys
Expand Down
28 changes: 0 additions & 28 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,34 +598,6 @@ class Index<T> extends MeiliAxiosWrapper implements Types.IndexInterface<T> {

return await this.delete(url)
}

///
/// ACCEPT NEW FIELDS
///

/**
* Get the accept-new-fields value.
* @memberof Index
* @method getAcceptNewFields
*/
async getAcceptNewFields(): Promise<boolean> {
const url = `/indexes/${this.uid}/settings/accept-new-fields`

return await this.get(url)
}

/**
* Update the accept-new-fields value.
* @memberof Index
* @method updateAcceptNewFields
*/
async updateAcceptNewFields(
acceptNewFields: boolean
): Promise<Types.EnqueuedUpdate> {
const url = `/indexes/${this.uid}/settings/accept-new-fields`

return await this.post(url, acceptNewFields)
}
}

export { Index }
3 changes: 0 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ export interface Settings {
synonyms?: {
[field: string]: string[]
}
acceptNewFields?: boolean
}

/*
Expand Down Expand Up @@ -344,8 +343,6 @@ export interface IndexInterface<T = any> extends MeiliAxiosWrapperInterface {
displayedAttributes: string[]
) => Promise<EnqueuedUpdate>
resetDisplayedAttributes: () => Promise<EnqueuedUpdate>
getAcceptNewFields: () => Promise<boolean>
updateAcceptNewFields: (acceptNewFields: boolean) => Promise<EnqueuedUpdate>
}

export interface MeiliAxiosWrapperInterface {
Expand Down
76 changes: 0 additions & 76 deletions tests/accept_new_fields_tests.ts

This file was deleted.

4 changes: 2 additions & 2 deletions tests/displayed_attributes_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe.each([
.getIndex(index.uid)
.getDisplayedAttributes()
.then((response: string[]) => {
expect(response.sort()).toEqual(Object.keys(dataset[0]).sort())
expect(response).toEqual(['*'])
})
})
test(`${permission} key: Update displayed attributes`, async () => {
Expand Down Expand Up @@ -83,7 +83,7 @@ describe.each([
.getIndex(index.uid)
.getDisplayedAttributes()
.then((response: string[]) => {
expect(response.sort()).toEqual(Object.keys(dataset[0]).sort())
expect(response).toEqual(['*'])
})
})
})
Expand Down
12 changes: 6 additions & 6 deletions tests/get_or_create_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ describe.each([{ client: publicClient, permission: 'Public' }])(
'Test on getOrCreateIndex',
({ client, permission }) => {
test(`${permission} key: try to getOrCreateIndex and be denied`, async () => {
await expect(
client.getIndex(index.uid).getAcceptNewFields()
).rejects.toThrowError(`Invalid API key: ${PUBLIC_KEY}`)
await expect(client.getOrCreateIndex(index.uid)).rejects.toThrowError(
`Invalid API key: ${PUBLIC_KEY}`
)
})
}
)
Expand All @@ -62,9 +62,9 @@ describe.each([{ client: anonymousClient, permission: 'No' }])(
'Test on getOrCreateIndex',
({ client, permission }) => {
test(`${permission} key: try to getOrCreateIndex and be denied`, async () => {
await expect(
client.getIndex(index.uid).getAcceptNewFields()
).rejects.toThrowError(`You must have an authorization token`)
await expect(client.getOrCreateIndex(index.uid)).rejects.toThrowError(
`You must have an authorization token`
)
})
}
)
4 changes: 2 additions & 2 deletions tests/searchable_attributes_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe.each([
.getIndex(index.uid)
.getSearchableAttributes()
.then((response: string[]) => {
expect(response.sort()).toEqual(Object.keys(dataset[0]).sort())
expect(response).toEqual(['*'])
})
})
test(`${permission} key: Update searchable attributes`, async () => {
Expand Down Expand Up @@ -83,7 +83,7 @@ describe.each([
.getIndex(index.uid)
.getSearchableAttributes()
.then((response: string[]) => {
expect(response.sort()).toEqual(Object.keys(dataset[0]).sort())
expect(response).toEqual(['*'])
})
})
})
Expand Down
Loading

0 comments on commit 57e5c52

Please sign in to comment.