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
@@ -1,65 +1,65 @@
|
||||
import '@testing-library/jest-dom/extend-expect';
|
||||
import "@testing-library/jest-dom/extend-expect";
|
||||
|
||||
jest.mock("../../api/endpoints");
|
||||
import { statefulSetApi } from "../../api/endpoints";
|
||||
import { StatefulSetScaleDialog } from "./statefulset-scale-dialog";
|
||||
import { render, waitFor, fireEvent } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { render, waitFor, fireEvent } from "@testing-library/react";
|
||||
import React from "react";
|
||||
|
||||
const dummyStatefulSet = {
|
||||
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: {
|
||||
serviceName: 'dummy',
|
||||
serviceName: "dummy",
|
||||
replicas: 1,
|
||||
selector: {
|
||||
matchLabels: { 'label': 'label' }
|
||||
matchLabels: { "label": "label" }
|
||||
},
|
||||
template: {
|
||||
metadata: {
|
||||
labels: {
|
||||
app: 'app',
|
||||
app: "app",
|
||||
},
|
||||
},
|
||||
spec: {
|
||||
containers: [{
|
||||
name: 'dummy',
|
||||
image: 'dummy',
|
||||
name: "dummy",
|
||||
image: "dummy",
|
||||
ports: [{
|
||||
containerPort: 1234,
|
||||
name: 'dummy',
|
||||
name: "dummy",
|
||||
}],
|
||||
volumeMounts: [{
|
||||
name: 'dummy',
|
||||
mountPath: 'dummy',
|
||||
name: "dummy",
|
||||
mountPath: "dummy",
|
||||
}],
|
||||
}],
|
||||
tolerations: [{
|
||||
key: 'dummy',
|
||||
operator: 'dummy',
|
||||
effect: 'dummy',
|
||||
key: "dummy",
|
||||
operator: "dummy",
|
||||
effect: "dummy",
|
||||
tolerationSeconds: 1,
|
||||
}],
|
||||
},
|
||||
},
|
||||
volumeClaimTemplates: [{
|
||||
metadata: {
|
||||
name: 'dummy',
|
||||
name: "dummy",
|
||||
},
|
||||
spec: {
|
||||
accessModes: ['dummy'],
|
||||
accessModes: ["dummy"],
|
||||
resources: {
|
||||
requests: {
|
||||
storage: 'dummy',
|
||||
storage: "dummy",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -70,8 +70,8 @@ const dummyStatefulSet = {
|
||||
replicas: 1,
|
||||
currentReplicas: 1,
|
||||
readyReplicas: 1,
|
||||
currentRevision: 'dummy',
|
||||
updateRevision: 'dummy',
|
||||
currentRevision: "dummy",
|
||||
updateRevision: "dummy",
|
||||
collisionCount: 1,
|
||||
},
|
||||
|
||||
@@ -98,13 +98,13 @@ const dummyStatefulSet = {
|
||||
delete: jest.fn(),
|
||||
};
|
||||
|
||||
describe('<StatefulSetScaleDialog />', () => {
|
||||
it('renders w/o errors', () => {
|
||||
describe("<StatefulSetScaleDialog />", () => {
|
||||
it("renders w/o errors", () => {
|
||||
const { container } = render(<StatefulSetScaleDialog/>);
|
||||
expect(container).toBeInstanceOf(HTMLElement);
|
||||
});
|
||||
|
||||
it('init with a dummy stateful set and mocked current/desired scale', async () => {
|
||||
it("init with a dummy stateful set and mocked current/desired scale", async () => {
|
||||
// mock statefulSetApi.getReplicas() which will be called
|
||||
// when <StatefulSetScaleDialog /> rendered.
|
||||
const initReplicas = 1;
|
||||
@@ -115,53 +115,53 @@ describe('<StatefulSetScaleDialog />', () => {
|
||||
// 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}`);
|
||||
});
|
||||
});
|
||||
|
||||
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;
|
||||
statefulSetApi.getReplicas = jest.fn().mockImplementationOnce(async () => initReplicas);
|
||||
const component = render(<StatefulSetScaleDialog/>);
|
||||
StatefulSetScaleDialog.open(dummyStatefulSet);
|
||||
await waitFor(async () => {
|
||||
expect(await component.findByTestId('desired-scale')).toHaveTextContent(`${initReplicas}`);
|
||||
expect(await component.findByTestId('current-scale')).toHaveTextContent(`${initReplicas}`);
|
||||
expect((await component.baseElement.querySelector('input').value)).toBe(`${initReplicas}`);
|
||||
expect(await component.findByTestId("desired-scale")).toHaveTextContent(`${initReplicas}`);
|
||||
expect(await component.findByTestId("current-scale")).toHaveTextContent(`${initReplicas}`);
|
||||
expect((await component.baseElement.querySelector("input").value)).toBe(`${initReplicas}`);
|
||||
});
|
||||
|
||||
const up = await component.findByTestId('desired-replicas-up');
|
||||
const down = await component.findByTestId('desired-replicas-down');
|
||||
const up = await component.findByTestId("desired-replicas-up");
|
||||
const down = await component.findByTestId("desired-replicas-down");
|
||||
fireEvent.click(up);
|
||||
expect(await component.findByTestId('desired-scale')).toHaveTextContent(`${initReplicas + 1}`);
|
||||
expect(await component.findByTestId('current-scale')).toHaveTextContent(`${initReplicas}`);
|
||||
expect((await component.baseElement.querySelector('input').value)).toBe(`${initReplicas + 1}`);
|
||||
expect(await component.findByTestId("desired-scale")).toHaveTextContent(`${initReplicas + 1}`);
|
||||
expect(await component.findByTestId("current-scale")).toHaveTextContent(`${initReplicas}`);
|
||||
expect((await component.baseElement.querySelector("input").value)).toBe(`${initReplicas + 1}`);
|
||||
|
||||
fireEvent.click(down);
|
||||
expect(await component.findByTestId('desired-scale')).toHaveTextContent(`${initReplicas}`);
|
||||
expect(await component.findByTestId('current-scale')).toHaveTextContent(`${initReplicas}`);
|
||||
expect((await component.baseElement.querySelector('input').value)).toBe(`${initReplicas}`);
|
||||
expect(await component.findByTestId("desired-scale")).toHaveTextContent(`${initReplicas}`);
|
||||
expect(await component.findByTestId("current-scale")).toHaveTextContent(`${initReplicas}`);
|
||||
expect((await component.baseElement.querySelector("input").value)).toBe(`${initReplicas}`);
|
||||
|
||||
// edge case, desiredScale must >= 0
|
||||
let times = 10;
|
||||
for (let i = 0; i < times; i++) {
|
||||
fireEvent.click(down);
|
||||
}
|
||||
expect(await component.findByTestId('desired-scale')).toHaveTextContent('0');
|
||||
expect((await component.baseElement.querySelector('input').value)).toBe('0');
|
||||
expect(await component.findByTestId("desired-scale")).toHaveTextContent("0");
|
||||
expect((await component.baseElement.querySelector("input").value)).toBe("0");
|
||||
|
||||
// edge case, desiredScale must <= scaleMax (100)
|
||||
times = 120;
|
||||
for (let i = 0; i < times; i++) {
|
||||
fireEvent.click(up);
|
||||
}
|
||||
expect(await component.findByTestId('desired-scale')).toHaveTextContent('100');
|
||||
expect((component.baseElement.querySelector("input").value)).toBe('100');
|
||||
expect(await component.findByTestId('warning'))
|
||||
.toHaveTextContent('High number of replicas may cause cluster performance issues');
|
||||
expect(await component.findByTestId("desired-scale")).toHaveTextContent("100");
|
||||
expect((component.baseElement.querySelector("input").value)).toBe("100");
|
||||
expect(await component.findByTestId("warning"))
|
||||
.toHaveTextContent("High number of replicas may cause cluster performance issues");
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,7 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { RouteComponentProps } from "react-router";
|
||||
import { t, Trans } from "@lingui/macro";
|
||||
import { StatefulSet, statefulSetApi } from "../../api/endpoints";
|
||||
import { StatefulSet } from "../../api/endpoints";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { statefulSetStore } from "./statefulset.store";
|
||||
import { nodesStore } from "../+nodes/nodes.store";
|
||||
@@ -64,7 +64,7 @@ export class StatefulSets extends React.Component<Props> {
|
||||
statefulSet.getNs(),
|
||||
this.renderPods(statefulSet),
|
||||
statefulSet.getReplicas(),
|
||||
<KubeObjectStatusIcon object={statefulSet}/>,
|
||||
<KubeObjectStatusIcon key="icon" object={statefulSet}/>,
|
||||
statefulSet.getAge(),
|
||||
]}
|
||||
renderItemMenu={(item: StatefulSet) => {
|
||||
|
||||
Reference in new issue
Block a user