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

* use value prop instead of depracted checked prop

* make sure props are not changed for all tests

(cherry picked from commit d1c7db5365)

Co-authored-by: Erik Sundell <erik.sundell@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2021-12-02 13:46:04 +01:00
committed by GitHub
co-authored by Erik Sundell
parent 3e7d7f55c6
commit 621e5bfdb4
2 changed files with 14 additions and 1 deletions
@@ -87,4 +87,16 @@ describe('MetricStatEditor', () => {
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();
});
});
});
@@ -109,7 +109,8 @@ export function MetricStatEditor({
tooltip="Only show metrics that exactly match all defined dimension names."
>
<Switch
checked={!!query.matchExact}
id="cloudwatch-match-exact"
value={!!query.matchExact}
onChange={(e) => {
onQueryChange({
...query,