mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Refactor after rebase from master
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
This commit is contained in:
parent
d07c292f99
commit
a807be545b
@ -107,17 +107,17 @@ describe('<DeploymentScaleDialog />', () => {
|
||||
deploymentApi.getReplicas = jest.fn().mockImplementationOnce(async () => initReplicas);
|
||||
const { getByTestId } = render(<DeploymentScaleDialog />);
|
||||
DeploymentScaleDialog.open(dummyDeployment);
|
||||
let currentScale, desiredScale
|
||||
// we need to wait for the DeploymentScaleDialog to show up
|
||||
// because there is an <Animate /> in <Dialog /> which renders null at start.
|
||||
await waitFor(async () =>
|
||||
[currentScale, desiredScale] = await Promise.all([
|
||||
await waitFor(async () => {
|
||||
const [currentScale, desiredScale] = await Promise.all([
|
||||
getByTestId('current-scale'),
|
||||
getByTestId('desired-scale'),
|
||||
])
|
||||
);
|
||||
expect(currentScale).toHaveTextContent(`${initReplicas}`);
|
||||
expect(desiredScale).toHaveTextContent(`${initReplicas}`);
|
||||
expect(currentScale).toHaveTextContent(`${initReplicas}`);
|
||||
expect(desiredScale).toHaveTextContent(`${initReplicas}`);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('changes the desired scale when clicking the icon buttons +/-', async () => {
|
||||
@ -125,30 +125,26 @@ describe('<DeploymentScaleDialog />', () => {
|
||||
deploymentApi.getReplicas = jest.fn().mockImplementationOnce(async () => initReplicas);
|
||||
const { getByTestId } = render(<DeploymentScaleDialog />);
|
||||
DeploymentScaleDialog.open(dummyDeployment);
|
||||
let desiredScale, up, down
|
||||
await waitFor(async () =>
|
||||
[desiredScale, up, down] = await Promise.all([
|
||||
getByTestId('desired-scale'),
|
||||
getByTestId('desired-replicas-up'),
|
||||
getByTestId('desired-replicas-down'),
|
||||
])
|
||||
);
|
||||
// initially, the desired scale should equals to initReplicas
|
||||
expect(desiredScale).toHaveTextContent(`${initReplicas}`);
|
||||
await waitFor(async () => {
|
||||
const desiredScale = await getByTestId('desired-scale');
|
||||
expect(desiredScale).toHaveTextContent(`${initReplicas}`);
|
||||
});
|
||||
const up = await getByTestId('desired-replicas-up');
|
||||
const down = await getByTestId('desired-replicas-down')
|
||||
fireEvent.click(up);
|
||||
expect(desiredScale).toHaveTextContent('2');
|
||||
expect(await getByTestId('desired-scale')).toHaveTextContent(`${initReplicas + 1}`);
|
||||
fireEvent.click(down);
|
||||
expect(desiredScale).toHaveTextContent('1');
|
||||
expect(await getByTestId('desired-scale')).toHaveTextContent('1');
|
||||
// edge case, desiredScale must > 0
|
||||
fireEvent.click(down);
|
||||
fireEvent.click(down);
|
||||
expect(desiredScale).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(desiredScale).toHaveTextContent('100');
|
||||
expect(await getByTestId('desired-scale')).toHaveTextContent('100');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user