Skip to content

Commit

Permalink
Automatic code-style change (#1665)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Martinez Gotor authored Apr 14, 2020
1 parent 60550a2 commit 2d34b88
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 42 deletions.
33 changes: 26 additions & 7 deletions dashboard/src/actions/apps.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,12 @@ describe("deploy chart", () => {

it("returns false and dispatches UnprocessableEntity if the namespace is _all", async () => {
const res = await store.dispatch(
actions.apps.deployChart("my-version" as any, "chart-namespace", "my-release", definedNamespaces.all),
actions.apps.deployChart(
"my-version" as any,
"chart-namespace",
"my-release",
definedNamespaces.all,
),
);
expect(res).toBe(false);
const expectedActions = [
Expand All @@ -256,9 +261,16 @@ describe("deploy chart", () => {
});
it("returns false and dispatches UnprocessableEntity if the given values don't satisfy the schema ", async () => {
const res = await store.dispatch(
actions.apps.deployChart("my-version" as any, "chart-namespace", "my-release", "default", "foo: 1", {
properties: { foo: { type: "string" } },
}),
actions.apps.deployChart(
"my-version" as any,
"chart-namespace",
"my-release",
"default",
"foo: 1",
{
properties: { foo: { type: "string" } },
},
),
);
expect(res).toBe(false);
const expectedActions = [
Expand Down Expand Up @@ -320,9 +332,16 @@ describe("upgradeApp", () => {

it("returns false and dispatches UnprocessableEntity if the given values don't satisfy the schema ", async () => {
const res = await store.dispatch(
actions.apps.upgradeApp("my-version" as any, "kubeapps-ns", "my-release", "default", "foo: 1", {
properties: { foo: { type: "string" } },
}),
actions.apps.upgradeApp(
"my-version" as any,
"kubeapps-ns",
"my-release",
"default",
"foo: 1",
{
properties: { foo: { type: "string" } },
},
),
);

expect(res).toBe(false);
Expand Down
12 changes: 9 additions & 3 deletions dashboard/src/actions/charts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ describe("getChartVersion", () => {
payload: { chartVersion: response, schema: { data: response }, values: { data: response } },
},
];
await store.dispatch(actions.charts.getChartVersion(namespace, "foo", "1.0.0-alpha+1.2.3-beta2"));
await store.dispatch(
actions.charts.getChartVersion(namespace, "foo", "1.0.0-alpha+1.2.3-beta2"),
);
expect(store.getActions()).toEqual(expectedActions);
expect(axiosGetMock.mock.calls[0][0]).toBe(
`api/assetsvc/v1/ns/${namespace}/charts/foo/versions/1.0.0-alpha%2B1.2.3-beta2`,
Expand Down Expand Up @@ -219,7 +221,9 @@ describe("fetchChartVersionsAndSelectVersion", () => {
{ type: getType(actions.charts.receiveChartVersions), payload: response },
{ type: getType(actions.charts.selectChartVersion), payload: { chartVersion: response[0] } },
];
await store.dispatch(actions.charts.fetchChartVersionsAndSelectVersion(namespace, "foo", "1.0.0"));
await store.dispatch(
actions.charts.fetchChartVersionsAndSelectVersion(namespace, "foo", "1.0.0"),
);
expect(store.getActions()).toEqual(expectedActions);
expect(axiosGetMock.mock.calls[0][0]).toBe(
`api/assetsvc/v1/ns/${namespace}/charts/foo/versions`,
Expand All @@ -239,7 +243,9 @@ describe("fetchChartVersionsAndSelectVersion", () => {
throw new Error("could not find chart");
});
axiosWithAuth.get = axiosGetMock;
await store.dispatch(actions.charts.fetchChartVersionsAndSelectVersion(namespace, "foo", "1.0.0"));
await store.dispatch(
actions.charts.fetchChartVersionsAndSelectVersion(namespace, "foo", "1.0.0"),
);
expect(store.getActions()).toEqual(expectedActions);
expect(axiosGetMock.mock.calls[0][0]).toBe(
`api/assetsvc/v1/ns/${namespace}/charts/foo/versions`,
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/actions/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function fetchChartVersions(
namespace: string,
id: string,
): ThunkAction<Promise<IChartVersion[] | undefined>, IStoreState, null, ChartsAction> {
return async dispatch => {
return async dispatch => {
dispatch(requestCharts());
try {
const versions = await Chart.fetchChartVersions(namespace, id);
Expand Down
24 changes: 20 additions & 4 deletions dashboard/src/components/AppUpgrade/AppUpgrade.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ describe("when receiving new props", () => {
);
wrapper.setProps({ repoName: "stable", app });
wrapper.update();
expect(getDeployedChartVersion).toHaveBeenCalledWith(defaultProps.repoNamespace, "stable/bar", "1.0.0");
expect(getDeployedChartVersion).toHaveBeenCalledWith(
defaultProps.repoNamespace,
"stable/bar",
"1.0.0",
);
});

it("should request the deployed chart when the repo is populated later", () => {
Expand All @@ -257,7 +261,11 @@ describe("when receiving new props", () => {
expect(getDeployedChartVersion).not.toHaveBeenCalled();
wrapper.setProps({ repoName: "stable" });
wrapper.update();
expect(getDeployedChartVersion).toHaveBeenCalledWith(defaultProps.repoNamespace, "stable/bar", "1.0.0");
expect(getDeployedChartVersion).toHaveBeenCalledWith(
defaultProps.repoNamespace,
"stable/bar",
"1.0.0",
);
});

it("a new app should re-trigger the deployed chart retrieval", () => {
Expand All @@ -274,7 +282,11 @@ describe("when receiving new props", () => {
<AppUpgrade {...defaultProps} getDeployedChartVersion={getDeployedChartVersion} />,
);
wrapper.setProps({ repoName: "stable", app });
expect(getDeployedChartVersion).toHaveBeenCalledWith(defaultProps.repoNamespace, "stable/bar", "1.0.0");
expect(getDeployedChartVersion).toHaveBeenCalledWith(
defaultProps.repoNamespace,
"stable/bar",
"1.0.0",
);

const app2 = {
chart: {
Expand All @@ -285,6 +297,10 @@ describe("when receiving new props", () => {
},
} as IRelease;
wrapper.setProps({ app: app2 });
expect(getDeployedChartVersion).toHaveBeenCalledWith(defaultProps.repoNamespace, "stable/foobar", "1.0.0");
expect(getDeployedChartVersion).toHaveBeenCalledWith(
defaultProps.repoNamespace,
"stable/foobar",
"1.0.0",
);
});
});
12 changes: 10 additions & 2 deletions dashboard/src/components/Catalog/Catalog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,20 @@ describe("renderization", () => {
items: [
{
id: "foo",
attributes: { name: "foo", description: "", repo: { name: "foo", namespace: "chart-namespace"} },
attributes: {
name: "foo",
description: "",
repo: { name: "foo", namespace: "chart-namespace" },
},
relationships: { latestChartVersion: { data: { app_version: "v1.0.0" } } },
} as IChart,
{
id: "bar",
attributes: { name: "bar", description: "", repo: { name: "bar", namespace: "chart-namespace"} },
attributes: {
name: "bar",
description: "",
repo: { name: "bar", namespace: "chart-namespace" },
},
relationships: { latestChartVersion: { data: { app_version: "v2.0.0" } } },
} as IChart,
],
Expand Down
3 changes: 2 additions & 1 deletion dashboard/src/components/Catalog/CatalogItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const CatalogItem: React.SFC<ICatalogItemProps> = props => {
let subIcon;
if (type === "chart") {
tag1 = (
<Link className="ListItem__content__info_tag_link"
<Link
className="ListItem__content__info_tag_link"
to={`/ns/${namespace}/catalog/${repo?.name}`}
>
{repo?.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ it("renders a button to deploy the chart version", () => {

it("renders a redirect with the correct URL when the button is clicked", () => {
const testCases = [
{ namespace: "kubeapps", version: "1.2.3", url: "/ns/kubeapps/apps/new/testrepo/test/versions/1.2.3" },
{
namespace: "kubeapps",
version: "1.2.3",
url: "/ns/kubeapps/apps/new/testrepo/test/versions/1.2.3",
},
{
namespace: "foo",
version: "alpha-0",
Expand Down
17 changes: 4 additions & 13 deletions dashboard/src/components/ChartView/ChartReadme.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,19 @@ it("renders the ReactMarkdown content is readme is present", () => {
const props = {
...defaultProps,
readme: "# Markdown Readme",
}
const wrapper = shallow(
<ChartReadme {...props} />,
);
};
const wrapper = shallow(<ChartReadme {...props} />);
const component = wrapper.find(ReactMarkdown);
expect(component.props()).toMatchObject({ source: "# Markdown Readme" });
});

it("renders an error when hasError is set", () => {
const wrapper = shallow(
<ChartReadme {...defaultProps} hasError={true} />,
);
const wrapper = shallow(<ChartReadme {...defaultProps} hasError={true} />);
expect(wrapper.text()).toContain("No README found");
});

it("renders the ReactMarkdown content adding IDs for the titles", () => {
const wrapper = mount(
<ChartReadme
{...defaultProps}
readme="# _Markdown_ 'Readme_or_not'!"
/>,
);
const wrapper = mount(<ChartReadme {...defaultProps} readme="# _Markdown_ 'Readme_or_not'!" />);
const component = wrapper.find("#markdown-readme_or_not");
expect(component).toExist();
});
Expand Down
14 changes: 12 additions & 2 deletions dashboard/src/components/DeploymentForm/DeploymentForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ afterEach(() => {
it("fetches the available versions", () => {
const fetchChartVersions = jest.fn();
shallow(<DeploymentForm {...defaultProps} fetchChartVersions={fetchChartVersions} />);
expect(fetchChartVersions).toHaveBeenCalledWith(defaultProps.chartNamespace, defaultProps.chartID);
expect(fetchChartVersions).toHaveBeenCalledWith(
defaultProps.chartNamespace,
defaultProps.chartID,
);
});

describe("renders an error", () => {
Expand Down Expand Up @@ -179,7 +182,14 @@ it("triggers a deployment when submitting the form", done => {
);
wrapper.setState({ appValues });
wrapper.find("form").simulate("submit");
expect(deployChart).toHaveBeenCalledWith(versions[0], defaultProps.chartNamespace, releaseName, namespace, appValues, schema);
expect(deployChart).toHaveBeenCalledWith(
versions[0],
defaultProps.chartNamespace,
releaseName,
namespace,
appValues,
schema,
);
setTimeout(() => {
expect(push).toHaveBeenCalledWith("/ns/default/apps/my-release");
done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ class DeploymentFormBody extends React.Component<
}

public componentDidUpdate = (prevProps: IDeploymentFormBodyProps) => {
const { chartID, chartNamespace, chartVersion, getChartVersion, selected, appValues } = this.props;
const {
chartID,
chartNamespace,
chartVersion,
getChartVersion,
selected,
appValues,
} = this.props;

if (chartVersion !== prevProps.chartVersion) {
// New version detected
Expand Down
14 changes: 12 additions & 2 deletions dashboard/src/components/UpgradeForm/UpgradeForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ itBehavesLike("aLoadingComponent", {
it("fetches the available versions", () => {
const fetchChartVersions = jest.fn();
shallow(<UpgradeForm {...defaultProps} fetchChartVersions={fetchChartVersions} />);
expect(fetchChartVersions).toHaveBeenCalledWith(defaultProps.repoNamespace, `${defaultProps.repo}/${defaultProps.chartName}`);
expect(fetchChartVersions).toHaveBeenCalledWith(
defaultProps.repoNamespace,
`${defaultProps.repo}/${defaultProps.chartName}`,
);
});

describe("renders an error", () => {
Expand Down Expand Up @@ -108,7 +111,14 @@ it("triggers an upgrade when submitting the form", done => {
);
wrapper.setState({ releaseName, appValues });
wrapper.find("form").simulate("submit");
expect(upgradeApp).toHaveBeenCalledWith(versions[0], "kubeapps", releaseName, namespace, appValues, schema);
expect(upgradeApp).toHaveBeenCalledWith(
versions[0],
"kubeapps",
releaseName,
namespace,
appValues,
schema,
);
setTimeout(() => {
expect(push).toHaveBeenCalledWith("/ns/default/apps/my-release");
done();
Expand Down
8 changes: 6 additions & 2 deletions dashboard/src/containers/AppNewContainer/AppNewContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ function mapDispatchToProps(dispatch: ThunkDispatch<IStoreState, null, Action>)
namespace: string,
values?: string,
schema?: JSONSchema4,
) => dispatch(actions.apps.deployChart(version, chartNamespace, releaseName, namespace, values, schema)),
fetchChartVersions: (namespace: string, id: string) => dispatch(actions.charts.fetchChartVersions(namespace, id)),
) =>
dispatch(
actions.apps.deployChart(version, chartNamespace, releaseName, namespace, values, schema),
),
fetchChartVersions: (namespace: string, id: string) =>
dispatch(actions.charts.fetchChartVersions(namespace, id)),
getChartVersion: (namespace: string, id: string, version: string) =>
dispatch(actions.charts.getChartVersion(namespace, id, version)),
push: (location: string) => dispatch(push(location)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function mapDispatchToProps(dispatch: ThunkDispatch<IStoreState, null, Action>)
checkChart: (namespace: string, repo: string, chartName: string) =>
dispatch(actions.repos.checkChart(namespace, repo, chartName)),
clearRepo: () => dispatch(actions.repos.clearRepo()),
fetchChartVersions: (namespace: string, id: string) => dispatch(actions.charts.fetchChartVersions(namespace, id)),
fetchChartVersions: (namespace: string, id: string) =>
dispatch(actions.charts.fetchChartVersions(namespace, id)),
fetchRepositories: (namespace: string) => dispatch(actions.repos.fetchRepos(namespace)),
getAppWithUpdateInfo: (namespace: string, releaseName: string) =>
dispatch(actions.apps.getAppWithUpdateInfo(namespace, releaseName)),
Expand All @@ -65,7 +66,10 @@ function mapDispatchToProps(dispatch: ThunkDispatch<IStoreState, null, Action>)
namespace: string,
values?: string,
schema?: JSONSchema4,
) => dispatch(actions.apps.upgradeApp(version, chartNamespace, releaseName, namespace, values, schema)),
) =>
dispatch(
actions.apps.upgradeApp(version, chartNamespace, releaseName, namespace, values, schema),
),
getDeployedChartVersion: (namespace: string, id: string, version: string) =>
dispatch(actions.charts.getDeployedChartVersion(namespace, id, version)),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IStoreState } from "../../shared/types";

function mapStateToProps(
{ charts, operators, config }: IStoreState,
{ match: { params }, location }: RouteComponentProps<{ namespace: string, repo: string }>,
{ match: { params }, location }: RouteComponentProps<{ namespace: string; repo: string }>,
) {
return {
charts,
Expand Down

0 comments on commit 2d34b88

Please sign in to comment.