Skip to content

Commit

Permalink
Formatting and linting applied
Browse files Browse the repository at this point in the history
  • Loading branch information
flevi29 committed May 22, 2024
1 parent a8fd645 commit 78eb713
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 34 deletions.
42 changes: 21 additions & 21 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
/** @type {import('jest').Config} */
const config = {
rootDir: ".",
testMatch: ["<rootDir>/tests/**/*.ts?(x)"],
rootDir: '.',
testMatch: ['<rootDir>/tests/**/*.ts?(x)'],
verbose: true,
testPathIgnorePatterns: ["meilisearch-test-utils", "env"],
testPathIgnorePatterns: ['meilisearch-test-utils', 'env'],
collectCoverage: true,
coverageThreshold: {
global: {
"ts-jest": {
tsConfig: "<rootDir>/tsconfig.json",
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.json',
},
},
},
watchPlugins: [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname",
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
projects: [
{
preset: "ts-jest",
displayName: "browser",
testEnvironment: "jsdom",
testMatch: ["<rootDir>/tests/**/*.ts?(x)"],
preset: 'ts-jest',
displayName: 'browser',
testEnvironment: 'jsdom',
testMatch: ['<rootDir>/tests/**/*.ts?(x)'],
testPathIgnorePatterns: [
"meilisearch-test-utils",
"env/",
"token.test.ts",
'meilisearch-test-utils',
'env/',
'token.test.ts',
],
// make sure built-in Node.js fetch doesn't get replaced for consistency
globals: { fetch: global.fetch },
},
{
preset: "ts-jest",
displayName: "node",
testEnvironment: "node",
testMatch: ["<rootDir>/tests/**/*.ts?(x)"],
testPathIgnorePatterns: ["meilisearch-test-utils", "env/"],
preset: 'ts-jest',
displayName: 'node',
testEnvironment: 'node',
testMatch: ['<rootDir>/tests/**/*.ts?(x)'],
testPathIgnorePatterns: ['meilisearch-test-utils', 'env/'],
},
],
};
}

module.exports = config;
module.exports = config
5 changes: 1 addition & 4 deletions src/indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,7 @@ class Index<T extends Record<string, any> = Record<string, any>> {

return new EnqueuedTask(task)
} catch (e) {
if (
e instanceof MeiliSearchRequestError &&
isDocumentsDeletionQuery
) {
if (e instanceof MeiliSearchRequestError && isDocumentsDeletionQuery) {
e.message = versionErrorHintMessage(e.message, 'deleteDocuments')
} else if (e instanceof MeiliSearchApiError) {
e.message = versionErrorHintMessage(e.message, 'deleteDocuments')
Expand Down
10 changes: 8 additions & 2 deletions tests/documents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,20 @@ Hint: It might not be working because maybe you're not up to date with the Meili
const client = await getClient(permission)
await expect(
client.index(indexNoPk.uid).getDocument(1)
).rejects.toHaveProperty('cause.code', ErrorStatusCode.DOCUMENT_NOT_FOUND)
).rejects.toHaveProperty(
'cause.code',
ErrorStatusCode.DOCUMENT_NOT_FOUND
)
})

test(`${permission} key: Try to get deleted document from index that has a primary key`, async () => {
const client = await getClient(permission)
await expect(
client.index(indexPk.uid).getDocument(1)
).rejects.toHaveProperty('cause.code', ErrorStatusCode.DOCUMENT_NOT_FOUND)
).rejects.toHaveProperty(
'cause.code',
ErrorStatusCode.DOCUMENT_NOT_FOUND
)
})

test(`${permission} key: Add documents from index with no primary key by giving a primary key as parameter`, async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/embedders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe.each([{ permission: 'Master' }, { permission: 'Admin' }])(
const task: EnqueuedTask = await client
.index(index.uid)
.updateEmbedders(newEmbedder)
await client.waitForTask(task.taskUid, {timeOutMs: 60_000})
await client.waitForTask(task.taskUid, { timeOutMs: 60_000 })

const response: Embedders = await client.index(index.uid).getEmbedders()

Expand Down
2 changes: 1 addition & 1 deletion tests/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Test on updates', () => {
}
})

test('MeiliSearchApiError can be compared with the instanceof operator', async () => {
test('MeiliSearchApiError can be compared with the instanceof operator', () => {
expect(
new MeiliSearchApiError(new Response(), {
message: 'Some error',
Expand Down
10 changes: 8 additions & 2 deletions tests/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,10 @@ describe.each([
controller.abort()

searchPromise.catch((error: any) => {
expect(error).toHaveProperty('cause.message', 'This operation was aborted')
expect(error).toHaveProperty(
'cause.message',
'This operation was aborted'
)
})
})

Expand Down Expand Up @@ -1092,7 +1095,10 @@ describe.each([
})

searchBPromise.catch((error: any) => {
expect(error).toHaveProperty('cause.message', 'This operation was aborted')
expect(error).toHaveProperty(
'cause.message',
'This operation was aborted'
)
})
})

Expand Down
15 changes: 12 additions & 3 deletions tests/task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,10 @@ describe.each([{ permission: 'Master' }, { permission: 'Admin' }])(
await expect(
// @ts-expect-error testing wrong argument type
client.getTasks({ statuses: ['wrong'] })
).rejects.toHaveProperty('cause.code', ErrorStatusCode.INVALID_TASK_STATUSES)
).rejects.toHaveProperty(
'cause.code',
ErrorStatusCode.INVALID_TASK_STATUSES
)
})

// filters error code: INVALID_TASK_UIDS_FILTER
Expand All @@ -407,7 +410,10 @@ describe.each([{ permission: 'Master' }, { permission: 'Admin' }])(
await expect(
// @ts-expect-error testing wrong canceledBy type
client.getTasks({ canceledBy: ['wrong'] })
).rejects.toHaveProperty('cause.code', ErrorStatusCode.INVALID_TASK_CANCELED_BY)
).rejects.toHaveProperty(
'cause.code',
ErrorStatusCode.INVALID_TASK_CANCELED_BY
)
})

// filters error code: INVALID_TASK_DATE_FILTER
Expand Down Expand Up @@ -584,7 +590,10 @@ describe.each([{ permission: 'Master' }, { permission: 'Admin' }])(
await expect(
// @ts-expect-error testing wrong argument type
client.cancelTasks()
).rejects.toHaveProperty('cause.code', ErrorStatusCode.MISSING_TASK_FILTERS)
).rejects.toHaveProperty(
'cause.code',
ErrorStatusCode.MISSING_TASK_FILTERS
)
})

// delete: uid
Expand Down

0 comments on commit 78eb713

Please sign in to comment.