mirror of https://github.com/grafana/grafana.git
				
				
				
			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, |       metricNamespace: undefined, | ||||||
|       metricName: undefined, |       metricName: undefined, | ||||||
|       aggregation: undefined, |       aggregation: undefined, | ||||||
|  |       metricDefinition: undefined, | ||||||
|       timeGrain: '', |       timeGrain: '', | ||||||
|       dimensionFilters: [], |       dimensionFilters: [], | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue