Skip to content

Commit

Permalink
feat: make unit test pass
Browse files Browse the repository at this point in the history
Signed-off-by: suzhou <[email protected]>
  • Loading branch information
SuZhou-Joe committed May 10, 2023
1 parent 83638f0 commit ca37317
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ HTMLCollection [
<div
class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow euiFlexGroup--responsive"
>
<div
class="euiFlexItem"
>
0
unsaved changes.
</div>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ describe("<IndicesActions /> spec", () => {
onShrink: function (): void {
throw new Error("Function not implemented.");
},
getIndices: function (): Promise<void> {
throw new Error("Function not implemented.");
},
});

await waitFor(() => {
Expand Down Expand Up @@ -98,9 +95,6 @@ describe("<IndicesActions /> spec", () => {
onShrink: function (): void {
throw new Error("Function not implemented.");
},
getIndices: function (): Promise<void> {
throw new Error("Function not implemented.");
},
});

await waitFor(() => {
Expand All @@ -112,7 +106,7 @@ describe("<IndicesActions /> spec", () => {
userEvent.click(getByTestId("Open Confirm button"));

await waitFor(() => {
expect(browserServicesMock.commonService.apiCaller).toHaveBeenCalledTimes(1);
expect(browserServicesMock.commonService.apiCaller).toHaveBeenCalledTimes(2);
expect(browserServicesMock.commonService.apiCaller).toHaveBeenCalledWith({
endpoint: "transport.request",
data: {
Expand Down Expand Up @@ -155,9 +149,6 @@ describe("<IndicesActions /> spec", () => {
onShrink: function (): void {
throw new Error("Function not implemented.");
},
getIndices: function (): Promise<void> {
throw new Error("Function not implemented.");
},
});

await waitFor(() => {
Expand Down Expand Up @@ -230,9 +221,6 @@ describe("<IndicesActions /> spec", () => {
onShrink: function (): void {
throw new Error("Function not implemented.");
},
getIndices: function (): Promise<void> {
throw new Error("Function not implemented.");
},
});

await waitFor(() => {
Expand Down Expand Up @@ -271,9 +259,6 @@ describe("<IndicesActions /> spec", () => {
const history = createMemoryHistory();

const { container, getByTestId } = renderWithRouter({
getIndices(): Promise<void> {
return Promise.resolve(undefined);
},
history: history,
location: history.location,
onClose(): void {},
Expand Down Expand Up @@ -314,9 +299,6 @@ describe("<IndicesActions /> spec", () => {
const history = createMemoryHistory();

const { container, getByTestId } = renderWithRouter({
getIndices(): Promise<void> {
return Promise.resolve(undefined);
},
history: history,
location: history.location,
onClose(): void {},
Expand Down Expand Up @@ -370,9 +352,6 @@ describe("<IndicesActions /> spec", () => {
const history = createMemoryHistory();

const { container, getByTestId } = renderWithRouter({
getIndices(): Promise<void> {
return Promise.resolve(undefined);
},
history: history,
location: history.location,
onClose(): void {},
Expand Down Expand Up @@ -411,9 +390,6 @@ describe("<IndicesActions /> spec", () => {
const history = createMemoryHistory();

const { getByTestId } = renderWithRouter({
getIndices(): Promise<void> {
return Promise.resolve(undefined);
},
history: history,
location: history.location,
onClose(): void {},
Expand Down Expand Up @@ -450,9 +426,6 @@ describe("<IndicesActions /> spec", () => {
const history = createMemoryHistory();

const { getByTestId } = renderWithRouter({
getIndices(): Promise<void> {
return Promise.resolve(undefined);
},
history: history,
location: history.location,
onClose(): void {},
Expand Down Expand Up @@ -499,9 +472,6 @@ describe("<IndicesActions /> spec", () => {
onShrink: function (): void {
throw new Error("Function not implemented.");
},
getIndices: function (): Promise<void> {
throw new Error("Function not implemented.");
},
});

await waitFor(() => {
Expand Down Expand Up @@ -556,9 +526,6 @@ describe("<IndicesActions /> spec", () => {
onShrink: function (): void {
throw new Error("Function not implemented.");
},
getIndices: function (): Promise<void> {
throw new Error("Function not implemented.");
},
});

await waitFor(() => {
Expand Down Expand Up @@ -597,9 +564,6 @@ describe("<IndicesActions /> spec", () => {
onShrink: function (): void {
throw new Error("Function not implemented.");
},
getIndices: function (): Promise<void> {
throw new Error("Function not implemented.");
},
});

await waitFor(() => {
Expand Down
1 change: 0 additions & 1 deletion public/pages/Indices/containers/IndicesActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export interface IndicesActionsProps extends Pick<RouteComponentProps, "history"
onDelete: () => void;
onClose: () => void;
onShrink: () => void;
getIndices: () => Promise<void>;
}

export default function IndicesActions(props: IndicesActionsProps) {
Expand Down
21 changes: 1 addition & 20 deletions public/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { BrowserServices } from "../models/interfaces";
import { IndexOpBlocksType } from "./constants";
import { CatIndex, DataStream } from "../../server/models/interfaces";
import { IAlias } from "../pages/Aliases/interface";
import { ClusterInfo } from "../models/interfaces";
import { CommonService } from "../services";

export function getErrorMessage(err: any, defaultMessage: string) {
if (err && err.message) return err.message;
Expand Down Expand Up @@ -64,7 +62,7 @@ export const getClusterInfo = (props: { commonService: CommonService }): Promise
.then((res) => {
if (res && res.ok) {
return {
cluster_name: res.response.cluster_name,
cluster_name: res?.response?.cluster_name,
};
}

Expand Down Expand Up @@ -169,20 +167,3 @@ export async function filterBlockedItems<T>(
});
return result;
}
export const getClusterInfo = (props: { commonService: CommonService }): Promise<ClusterInfo> => {
return props.commonService
.apiCaller<{
cluster_name: string;
}>({
endpoint: "cluster.health",
})
.then((res) => {
if (res && res.ok) {
return {
cluster_name: res.response.cluster_name,
};
}

return {};
});
};

0 comments on commit ca37317

Please sign in to comment.