Skip to content

Commit

Permalink
Elastic suggester : fix data/ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmelisson committed Oct 29, 2019
1 parent e3878a7 commit dd94d54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,20 @@ describe("populate_suggestion", () => {
});

test("should create suggestionIndex", async () => {
await populateSuggestions("client");
await populateSuggestions("client", INDEX_NAME);
expect(createIndex).toHaveBeenCalledTimes(1);

expect(createIndex.mock.calls[0][0].client).toBe("client");
expect(
createIndex.mock.calls[0][0].indexName.startsWith(`${INDEX_NAME}-`)
).toBe(true);
expect(createIndex.mock.calls[0][0].indexName).toBe(INDEX_NAME);
});

test("should pushSuggestion", async () => {
await populateSuggestions("client");
await populateSuggestions("client", INDEX_NAME);
expect(indexDocumentsBatched).toHaveBeenCalledTimes(
Math.ceil(testCasesCount / BUFFER_SIZE)
);
expect(indexDocumentsBatched.mock.calls[0][0].client).toBe("client");
expect(
indexDocumentsBatched.mock.calls[0][0].indexName.startsWith(
`${INDEX_NAME}-`
)
).toBe(true);
expect(createIndex.mock.calls[0][0].indexName).toBe(INDEX_NAME);
expect(indexDocumentsBatched.mock.calls[0][0].documents)
.toMatchInlineSnapshot(`
Array [
Expand Down
2 changes: 1 addition & 1 deletion packages/code-du-travail-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"populate": "node ./dist/index.js",
"check-slugs": "node -r esm indexing/slug_checker",
"dump": "node -r esm dump.js",
"test": "jest"
"test": "BUFFER_SIZE=10 SUGGEST_FILE=./indexing/__tests__/suggestion_data_test.txt jest"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit dd94d54

Please sign in to comment.