mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
add no-unused and react/recommended to eslint (#1523)
* add no-unused-vars and no-unused-imports * added quotes: double, and remove ignore pattern * move itif and describeif into utils Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
10eb082854
commit
7451869c25
199 files changed
+1178
-807
No files matched your search
@@ -6,7 +6,7 @@ import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { t, Trans } from "@lingui/macro";
|
||||
import { DrawerItem } from "../drawer";
|
||||
import { Badge } from "../badge";
|
||||
import { Deployment, deploymentApi } from "../../api/endpoints";
|
||||
import { Deployment } from "../../api/endpoints";
|
||||
import { cssNames } from "../../utils";
|
||||
import { PodDetailsTolerations } from "../+workloads-pods/pod-details-tolerations";
|
||||
import { PodDetailsAffinities } from "../+workloads-pods/pod-details-affinities";
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
import React from 'react';
|
||||
import { render, waitFor, fireEvent } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom/extend-expect';
|
||||
import React from "react";
|
||||
import { render, waitFor, fireEvent } from "@testing-library/react";
|
||||
import "@testing-library/jest-dom/extend-expect";
|
||||
|
||||
import { DeploymentScaleDialog } from "./deployment-scale-dialog";
|
||||
jest.mock("../../api/endpoints");
|
||||
import { deploymentApi } from "../../api/endpoints";
|
||||
|
||||
const dummyDeployment = {
|
||||
apiVersion: 'v1',
|
||||
kind: 'dummy',
|
||||
apiVersion: "v1",
|
||||
kind: "dummy",
|
||||
metadata: {
|
||||
uid: 'dummy',
|
||||
name: 'dummy',
|
||||
creationTimestamp: 'dummy',
|
||||
resourceVersion: 'dummy',
|
||||
selfLink: 'link',
|
||||
uid: "dummy",
|
||||
name: "dummy",
|
||||
creationTimestamp: "dummy",
|
||||
resourceVersion: "dummy",
|
||||
selfLink: "link",
|
||||
},
|
||||
selfLink: 'link',
|
||||
selfLink: "link",
|
||||
spec: {
|
||||
replicas: 1,
|
||||
selector: { matchLabels: { dummy: 'label' } },
|
||||
selector: { matchLabels: { dummy: "label" } },
|
||||
template: {
|
||||
metadata: {
|
||||
labels: { dummy: 'label' },
|
||||
labels: { dummy: "label" },
|
||||
},
|
||||
spec: {
|
||||
containers: [{
|
||||
name: 'dummy',
|
||||
image: 'dummy',
|
||||
name: "dummy",
|
||||
image: "dummy",
|
||||
resources: {
|
||||
requests: {
|
||||
cpu: '1',
|
||||
memory: '10Mi',
|
||||
cpu: "1",
|
||||
memory: "10Mi",
|
||||
},
|
||||
},
|
||||
terminationMessagePath: 'dummy',
|
||||
terminationMessagePolicy: 'dummy',
|
||||
imagePullPolicy: 'dummy',
|
||||
terminationMessagePath: "dummy",
|
||||
terminationMessagePolicy: "dummy",
|
||||
imagePullPolicy: "dummy",
|
||||
}],
|
||||
restartPolicy: 'dummy',
|
||||
restartPolicy: "dummy",
|
||||
terminationGracePeriodSeconds: 10,
|
||||
dnsPolicy: 'dummy',
|
||||
serviceAccountName: 'dummy',
|
||||
serviceAccount: 'dummy',
|
||||
dnsPolicy: "dummy",
|
||||
serviceAccountName: "dummy",
|
||||
serviceAccount: "dummy",
|
||||
securityContext: {},
|
||||
schedulerName: 'dummy',
|
||||
schedulerName: "dummy",
|
||||
},
|
||||
},
|
||||
strategy: {
|
||||
type: 'dummy',
|
||||
type: "dummy",
|
||||
rollingUpdate: {
|
||||
maxUnavailable: 1,
|
||||
maxSurge: 10,
|
||||
@@ -61,12 +61,12 @@ const dummyDeployment = {
|
||||
updatedReplicas: 1,
|
||||
readyReplicas: 1,
|
||||
conditions: [{
|
||||
type: 'dummy',
|
||||
status: 'dummy',
|
||||
lastUpdateTime: 'dummy',
|
||||
lastTransitionTime: 'dummy',
|
||||
reason: 'dummy',
|
||||
message: 'dummy',
|
||||
type: "dummy",
|
||||
status: "dummy",
|
||||
lastUpdateTime: "dummy",
|
||||
lastTransitionTime: "dummy",
|
||||
reason: "dummy",
|
||||
message: "dummy",
|
||||
}],
|
||||
},
|
||||
getConditions: jest.fn(),
|
||||
@@ -93,14 +93,14 @@ const dummyDeployment = {
|
||||
delete: jest.fn(),
|
||||
};
|
||||
|
||||
describe('<DeploymentScaleDialog />', () => {
|
||||
describe("<DeploymentScaleDialog />", () => {
|
||||
|
||||
it('renders w/o errors', () => {
|
||||
it("renders w/o errors", () => {
|
||||
const { container } = render(<DeploymentScaleDialog />);
|
||||
expect(container).toBeInstanceOf(HTMLElement);
|
||||
});
|
||||
|
||||
it('inits with a dummy deployment with mocked current/desired scale', async () => {
|
||||
it("inits with a dummy deployment with mocked current/desired scale", async () => {
|
||||
// mock deploymentApi.getReplicas() which will be called
|
||||
// when <DeploymentScaleDialog /> rendered.
|
||||
const initReplicas = 3;
|
||||
@@ -111,8 +111,8 @@ describe('<DeploymentScaleDialog />', () => {
|
||||
// because there is an <Animate /> in <Dialog /> which renders null at start.
|
||||
await waitFor(async () => {
|
||||
const [currentScale, desiredScale] = await Promise.all([
|
||||
getByTestId('current-scale'),
|
||||
getByTestId('desired-scale'),
|
||||
getByTestId("current-scale"),
|
||||
getByTestId("desired-scale"),
|
||||
]);
|
||||
expect(currentScale).toHaveTextContent(`${initReplicas}`);
|
||||
expect(desiredScale).toHaveTextContent(`${initReplicas}`);
|
||||
@@ -120,31 +120,31 @@ describe('<DeploymentScaleDialog />', () => {
|
||||
|
||||
});
|
||||
|
||||
it('changes the desired scale when clicking the icon buttons +/-', async () => {
|
||||
it("changes the desired scale when clicking the icon buttons +/-", async () => {
|
||||
const initReplicas = 1;
|
||||
deploymentApi.getReplicas = jest.fn().mockImplementationOnce(async () => initReplicas);
|
||||
const { getByTestId } = render(<DeploymentScaleDialog />);
|
||||
DeploymentScaleDialog.open(dummyDeployment);
|
||||
await waitFor(async () => {
|
||||
const desiredScale = await getByTestId('desired-scale');
|
||||
const desiredScale = await getByTestId("desired-scale");
|
||||
expect(desiredScale).toHaveTextContent(`${initReplicas}`);
|
||||
});
|
||||
const up = await getByTestId('desired-replicas-up');
|
||||
const down = await getByTestId('desired-replicas-down');
|
||||
const up = await getByTestId("desired-replicas-up");
|
||||
const down = await getByTestId("desired-replicas-down");
|
||||
fireEvent.click(up);
|
||||
expect(await getByTestId('desired-scale')).toHaveTextContent(`${initReplicas + 1}`);
|
||||
expect(await getByTestId("desired-scale")).toHaveTextContent(`${initReplicas + 1}`);
|
||||
fireEvent.click(down);
|
||||
expect(await getByTestId('desired-scale')).toHaveTextContent('1');
|
||||
expect(await getByTestId("desired-scale")).toHaveTextContent("1");
|
||||
// edge case, desiredScale must > 0
|
||||
fireEvent.click(down);
|
||||
fireEvent.click(down);
|
||||
expect(await getByTestId('desired-scale')).toHaveTextContent('1');
|
||||
expect(await getByTestId("desired-scale")).toHaveTextContent("1");
|
||||
const times = 120;
|
||||
// edge case, desiredScale must < scaleMax (100)
|
||||
for (let i = 0; i < times; i++) {
|
||||
fireEvent.click(up);
|
||||
}
|
||||
expect(await getByTestId('desired-scale')).toHaveTextContent('100');
|
||||
expect(await getByTestId("desired-scale")).toHaveTextContent("100");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -80,7 +80,7 @@ export class Deployments extends React.Component<Props> {
|
||||
]}
|
||||
renderTableContents={(deployment: Deployment) => [
|
||||
deployment.getName(),
|
||||
<KubeObjectStatusIcon object={deployment}/>,
|
||||
<KubeObjectStatusIcon key="icon" object={deployment}/>,
|
||||
deployment.getNs(),
|
||||
this.renderPods(deployment),
|
||||
deployment.getReplicas(),
|
||||
|
||||
Reference in new issue
Block a user