-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: [M3-8565] - Add unit tests for rest of NodeBalancers package (#…
…10945) * quick eslint fixes * unit tests for nb passive check and delete dialog * starting tests for NodeBalancerConfigNode * nodebalancerconfignode tests * update tests in config panel to account for active check component * unit test for NodeBalancerCreate to confirm it renders * Added changeset: Add unit tests for rest of NodeBalancers package * Update packages/manager/src/features/NodeBalancers/NodeBalancerConfigNode.test.tsx Co-authored-by: Dajahi Wiley <114682940+dwiley-akamai@users.noreply.github.com> * Update packages/manager/src/features/NodeBalancers/NodeBalancerCreate.test.tsx Co-authored-by: Dajahi Wiley <114682940+dwiley-akamai@users.noreply.github.com> --------- Co-authored-by: Dajahi Wiley <114682940+dwiley-akamai@users.noreply.github.com>
- Loading branch information
1 parent
df32f28
commit 75c5986
Showing
9 changed files
with
303 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Tests | ||
--- | ||
|
||
Add unit tests for rest of NodeBalancers package ([#10945](https://github.com/linode/manager/pull/10945)) |
2 changes: 1 addition & 1 deletion
2
packages/manager/src/features/NodeBalancers/ConfigNodeIPSelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/manager/src/features/NodeBalancers/NodeBalancerConfigNode.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { fireEvent } from '@testing-library/react'; | ||
import * as React from 'react'; | ||
|
||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { NodeBalancerConfigNode } from './NodeBalancerConfigNode'; | ||
|
||
import type { NodeBalancerConfigNodeProps } from './NodeBalancerConfigNode'; | ||
|
||
const node = { | ||
address: 'some address', | ||
label: 'some label', | ||
}; | ||
|
||
const props: NodeBalancerConfigNodeProps = { | ||
configIdx: 1, | ||
disabled: false, | ||
forEdit: true, | ||
idx: 1, | ||
node, | ||
onNodeAddressChange: vi.fn(), | ||
onNodeLabelChange: vi.fn(), | ||
onNodeModeChange: vi.fn(), | ||
onNodePortChange: vi.fn(), | ||
onNodeWeightChange: vi.fn(), | ||
removeNode: vi.fn(), | ||
}; | ||
|
||
describe('NodeBalancerConfigNode', () => { | ||
it('renders the NodeBalancerConfigNode', () => { | ||
const { getByLabelText, getByText, queryByText } = renderWithTheme( | ||
<NodeBalancerConfigNode {...props} /> | ||
); | ||
|
||
expect(getByLabelText('Label')).toBeVisible(); | ||
expect(getByLabelText('Port')).toBeVisible(); | ||
expect(getByLabelText('Weight')).toBeVisible(); | ||
expect(getByText('Mode')).toBeVisible(); | ||
expect(getByText('Remove')).toBeVisible(); | ||
expect(queryByText('Status')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('renders the node status', () => { | ||
const { getByText } = renderWithTheme( | ||
<NodeBalancerConfigNode {...props} node={{ ...node, status: 'DOWN' }} /> | ||
); | ||
|
||
expect(getByText('Status')).toBeVisible(); | ||
expect(getByText('DOWN')).toBeVisible(); | ||
}); | ||
|
||
it('cannot change the mode if the node is not for edit', () => { | ||
const { queryByText } = renderWithTheme( | ||
<NodeBalancerConfigNode {...props} forEdit={false} /> | ||
); | ||
|
||
expect(queryByText('Mode')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('cannot remove the node if the node is not for edit or is the first node', () => { | ||
const { queryByText } = renderWithTheme( | ||
<NodeBalancerConfigNode {...props} forEdit={false} idx={0} /> | ||
); | ||
|
||
expect(queryByText('Remove')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('removes the node', () => { | ||
const { getByText } = renderWithTheme( | ||
<NodeBalancerConfigNode {...props} /> | ||
); | ||
|
||
fireEvent.click(getByText('Remove')); | ||
expect(props.removeNode).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.