CloudWatch: Make sure MatchExact flag gets the right value (#42621)

* use value prop instead of depracted checked prop

* make sure props are not changed for all tests
This commit is contained in:
Erik Sundell
2021-12-02 13:31:23 +01:00
committed by GitHub
parent 54fa7b57fe
commit d1c7db5365
2 changed files with 14 additions and 1 deletions

View File

@@ -87,4 +87,16 @@ describe('MetricStatEditor', () => {
expect(screen.queryByText('Match exact')).toBeNull(); expect(screen.queryByText('Match exact')).toBeNull();
}); });
}); });
describe('match exact', () => {
it('should be checked when value is true', () => {
render(<MetricStatEditor {...props} disableExpressions={false} />);
expect(screen.getByLabelText('Match exact - optional')).toBeChecked();
});
it('should be unchecked when value is false', () => {
render(<MetricStatEditor {...props} query={{ ...props.query, matchExact: false }} disableExpressions={false} />);
expect(screen.getByLabelText('Match exact - optional')).not.toBeChecked();
});
});
}); });

View File

@@ -109,7 +109,8 @@ export function MetricStatEditor({
tooltip="Only show metrics that exactly match all defined dimension names." tooltip="Only show metrics that exactly match all defined dimension names."
> >
<Switch <Switch
checked={!!query.matchExact} id="cloudwatch-match-exact"
value={!!query.matchExact}
onChange={(e) => { onChange={(e) => {
onQueryChange({ onQueryChange({
...query, ...query,