-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: disable options in legend or yaxis section if visible is false #…
- Loading branch information
1 parent
e1622c8
commit b4daa17
Showing
3 changed files
with
77 additions
and
1 deletion.
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
69 changes: 69 additions & 0 deletions
69
...shboard/src/customization/propertiesSections/lineAndScatterStyleSettings/section.spec.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,69 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import { LegendSection } from './legendSection'; | ||
import { YAxisSection } from './yAxis'; | ||
|
||
describe('YAxisSection', () => { | ||
test('should disable y axis options when visible is false', () => { | ||
const options = { | ||
visible: false, | ||
min: null, | ||
max: null, | ||
yLabel: null, | ||
setVisible: () => {}, | ||
updateMin: () => {}, | ||
updateMax: () => {}, | ||
updateYLabel: () => {}, | ||
}; | ||
const { getByPlaceholderText, getAllByPlaceholderText } = render( | ||
<YAxisSection {...options} /> | ||
); | ||
expect(getByPlaceholderText('Input Y-axis label')).toBeDisabled(); | ||
expect(getAllByPlaceholderText('Auto')[0]).toBeDisabled(); | ||
expect(getAllByPlaceholderText('Auto')[1]).toBeDisabled(); | ||
}); | ||
|
||
test('should not disable y axis options when visible is true', () => { | ||
const options = { | ||
visible: true, | ||
min: null, | ||
max: null, | ||
yLabel: null, | ||
setVisible: () => {}, | ||
updateMin: () => {}, | ||
updateMax: () => {}, | ||
updateYLabel: () => {}, | ||
}; | ||
const { getByPlaceholderText, getAllByPlaceholderText } = render( | ||
<YAxisSection {...options} /> | ||
); | ||
expect(getByPlaceholderText('Input Y-axis label')).not.toBeDisabled(); | ||
expect(getAllByPlaceholderText('Auto')[0]).not.toBeDisabled(); | ||
expect(getAllByPlaceholderText('Auto')[1]).not.toBeDisabled(); | ||
}); | ||
}); | ||
|
||
describe('LegendSection', () => { | ||
test('should disable legend options when visible is false', () => { | ||
const options = { | ||
visible: false, | ||
position: 'left', | ||
setVisible: () => {}, | ||
setAlignment: () => {}, | ||
}; | ||
const { getByLabelText } = render(<LegendSection {...options} />); | ||
expect(getByLabelText('Alignment')).toBeDisabled(); | ||
}); | ||
|
||
test('should not disable legend options when visible is true', () => { | ||
const options = { | ||
visible: true, | ||
position: 'left', | ||
setVisible: () => {}, | ||
setAlignment: () => {}, | ||
}; | ||
const { getByLabelText } = render(<LegendSection {...options} />); | ||
expect(getByLabelText('Alignment')).not.toBeDisabled(); | ||
}); | ||
}); |
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