mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AzureMonitor: Clean namespace when changing the resource (#50311)
This commit is contained in:
parent
f54adf6c22
commit
ae449cc823
@ -0,0 +1,31 @@
|
||||
import createMockQuery from '../../__mocks__/query';
|
||||
|
||||
import { setResource } from './setQueryValue';
|
||||
|
||||
describe('setResource', () => {
|
||||
it('should set a resource URI', () => {
|
||||
const q = setResource(createMockQuery(), '/new-uri');
|
||||
expect(q.azureMonitor?.resourceUri).toEqual('/new-uri');
|
||||
});
|
||||
|
||||
it('should remove clean up dependent fields', () => {
|
||||
const q = createMockQuery();
|
||||
expect(q.azureMonitor?.metricNamespace).not.toEqual(undefined);
|
||||
expect(q.azureMonitor?.metricName).not.toEqual(undefined);
|
||||
expect(q.azureMonitor?.metricDefinition).not.toEqual(undefined);
|
||||
expect(q.azureMonitor?.aggregation).not.toEqual(undefined);
|
||||
expect(q.azureMonitor?.metricDefinition).not.toEqual(undefined);
|
||||
expect(q.azureMonitor?.metricDefinition).not.toEqual(undefined);
|
||||
expect(q.azureMonitor?.timeGrain).not.toEqual('');
|
||||
expect(q.azureMonitor?.timeGrain).not.toEqual([]);
|
||||
const newQ = setResource(createMockQuery(), '/new-uri');
|
||||
expect(newQ.azureMonitor).toMatchObject({
|
||||
metricNamespace: undefined,
|
||||
metricName: undefined,
|
||||
aggregation: undefined,
|
||||
metricDefinition: undefined,
|
||||
timeGrain: '',
|
||||
dimensionFilters: [],
|
||||
});
|
||||
});
|
||||
});
|
@ -9,6 +9,7 @@ export function setResource(query: AzureMonitorQuery, resourceURI: string | unde
|
||||
metricNamespace: undefined,
|
||||
metricName: undefined,
|
||||
aggregation: undefined,
|
||||
metricDefinition: undefined,
|
||||
timeGrain: '',
|
||||
dimensionFilters: [],
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user