Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Nov 1, 2024
1 parent 244ea43 commit db0d336
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 102 deletions.
32 changes: 10 additions & 22 deletions public/JobHandler/callbacks/force_merge.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ describe("callbackForForceMerge spec", () => {

it("callback when not complete", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: false,
},
completed: false,
});
const result = await callbackForForceMerge(forceMergeMetaData, {
core,
Expand All @@ -54,10 +51,7 @@ describe("callbackForForceMerge spec", () => {

it("callback when complete", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: true,
},
completed: true,
});
const result = await callbackForForceMerge(forceMergeMetaData, {
core,
Expand All @@ -69,14 +63,11 @@ describe("callbackForForceMerge spec", () => {

it("callback when some complete", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: true,
response: {
_shards: {
successful: 9,
total: 10,
},
completed: true,
response: {
_shards: {
successful: 9,
total: 10,
},
},
});
Expand All @@ -90,12 +81,9 @@ describe("callbackForForceMerge spec", () => {

it("callback when failed", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: true,
error: {
reason: "reason",
},
completed: true,
error: {
reason: "reason",
},
});
const result = await callbackForForceMerge(forceMergeMetaData, {
Expand Down
25 changes: 8 additions & 17 deletions public/JobHandler/callbacks/open.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ describe("callbackForOpen spec", () => {

it("callback when not complete", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: false,
},
completed: false,
});
const result = await callbackForOpen(openMetaData, {
core,
Expand All @@ -53,13 +50,10 @@ describe("callbackForOpen spec", () => {

it("callback when successfully complete", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: true,
response: {
acknowledged: true,
shards_acknowledged: true,
},
completed: true,
response: {
acknowledged: true,
shards_acknowledged: true,
},
});
const result = await callbackForOpen(openMetaData, {
Expand All @@ -72,12 +66,9 @@ describe("callbackForOpen spec", () => {

it("callback when failed", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: true,
error: {
reason: "reason",
},
completed: true,
error: {
reason: "reason",
},
});
const result = await callbackForOpen(openMetaData, {
Expand Down
33 changes: 12 additions & 21 deletions public/JobHandler/callbacks/reindex.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ describe("callbackForOpen spec", () => {

it("callback when not complete", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: false,
},
completed: false,
});
const result = await callbackForReindex(reindexMetaData, {
core,
Expand All @@ -56,10 +53,7 @@ describe("callbackForOpen spec", () => {

it("callback when successfully complete", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: true,
},
completed: true,
});
const result = await callbackForReindex(reindexMetaData, {
core,
Expand All @@ -71,20 +65,17 @@ describe("callbackForOpen spec", () => {

it("callback when failed", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: true,
error: {
reason: "reason",
},
failures: [
{
cause: {
reason: "cause",
},
},
],
completed: true,
error: {
reason: "reason",
},
failures: [
{
cause: {
reason: "cause",
},
},
],
});
const result = await callbackForReindex(reindexMetaData, {
core,
Expand Down
33 changes: 12 additions & 21 deletions public/JobHandler/callbacks/shrink.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ describe("callbackForOpen spec", () => {

it("callback when not complete", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: false,
},
completed: false,
});
const result = await callbackForShrink(shrinkMetaData, {
core,
Expand All @@ -54,10 +51,7 @@ describe("callbackForOpen spec", () => {

it("callback when successfully complete", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: true,
},
completed: true,
});
const result = await callbackForShrink(shrinkMetaData, {
core,
Expand All @@ -69,20 +63,17 @@ describe("callbackForOpen spec", () => {

it("callback when failed", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: true,
error: {
reason: "reason",
},
failures: [
{
cause: {
reason: "cause",
},
},
],
completed: true,
error: {
reason: "reason",
},
failures: [
{
cause: {
reason: "cause",
},
},
],
});
const result = await callbackForShrink(shrinkMetaData, {
core,
Expand Down
33 changes: 12 additions & 21 deletions public/JobHandler/callbacks/split.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ describe("callbackForOpen spec", () => {

it("callback when not complete", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: false,
},
completed: false,
});
const result = await callbackForSplit(splitMetaData, {
core,
Expand All @@ -54,10 +51,7 @@ describe("callbackForOpen spec", () => {

it("callback when successfully complete", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: true,
},
completed: true,
});
const result = await callbackForSplit(splitMetaData, {
core,
Expand All @@ -69,20 +63,17 @@ describe("callbackForOpen spec", () => {

it("callback when failed", async () => {
httpClientMock.fetch = getMockFn({
found: true,
_source: {
completed: true,
error: {
reason: "reason",
},
failures: [
{
cause: {
reason: "cause",
},
},
],
completed: true,
error: {
reason: "reason",
},
failures: [
{
cause: {
reason: "cause",
},
},
],
});
const result = await callbackForSplit(splitMetaData, {
core,
Expand Down

0 comments on commit db0d336

Please sign in to comment.