|
|
|
@ -7,7 +7,7 @@ import { changeEditorMode, getQueryWithDefaults } from './state'; |
|
|
|
|
|
|
|
|
|
describe('getQueryWithDefaults(', () => { |
|
|
|
|
it('should set defaults', () => { |
|
|
|
|
expect(getQueryWithDefaults({ refId: 'A' } as PromQuery, CoreApp.Dashboard)).toEqual({ |
|
|
|
|
expect(getQueryWithDefaults({ expr: '', refId: 'A' } as PromQuery, CoreApp.Dashboard)).toEqual({ |
|
|
|
|
editorMode: 'builder', |
|
|
|
|
expr: '', |
|
|
|
|
legendFormat: '__auto', |
|
|
|
@ -17,7 +17,7 @@ describe('getQueryWithDefaults(', () => { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should set both range and instant to true when in Explore', () => { |
|
|
|
|
expect(getQueryWithDefaults({ refId: 'A' } as PromQuery, CoreApp.Explore)).toEqual({ |
|
|
|
|
expect(getQueryWithDefaults({ expr: '', refId: 'A' } as PromQuery, CoreApp.Explore)).toEqual({ |
|
|
|
|
editorMode: 'builder', |
|
|
|
|
expr: '', |
|
|
|
|
legendFormat: '__auto', |
|
|
|
@ -29,7 +29,7 @@ describe('getQueryWithDefaults(', () => { |
|
|
|
|
|
|
|
|
|
it('should not set both instant and range for Prometheus queries in Alert Creation', () => { |
|
|
|
|
expect( |
|
|
|
|
getQueryWithDefaults({ refId: 'A', range: true, instant: true } as PromQuery, CoreApp.UnifiedAlerting) |
|
|
|
|
getQueryWithDefaults({ expr: '', refId: 'A', range: true, instant: true } as PromQuery, CoreApp.UnifiedAlerting) |
|
|
|
|
).toEqual({ |
|
|
|
|
editorMode: 'builder', |
|
|
|
|
expr: '', |
|
|
|
@ -45,13 +45,15 @@ describe('getQueryWithDefaults(', () => { |
|
|
|
|
expect(query.editorMode).toBe(QueryEditorMode.Code); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
expect(getQueryWithDefaults({ refId: 'A' } as PromQuery, CoreApp.Dashboard).editorMode).toEqual( |
|
|
|
|
expect(getQueryWithDefaults({ expr: '', refId: 'A' } as PromQuery, CoreApp.Dashboard).editorMode).toEqual( |
|
|
|
|
QueryEditorMode.Code |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return default editor mode when it is provided', () => { |
|
|
|
|
expect(getQueryWithDefaults({ refId: 'A' } as PromQuery, CoreApp.Dashboard, QueryEditorMode.Code)).toEqual({ |
|
|
|
|
expect( |
|
|
|
|
getQueryWithDefaults({ expr: '', refId: 'A' } as PromQuery, CoreApp.Dashboard, QueryEditorMode.Code) |
|
|
|
|
).toEqual({ |
|
|
|
|
editorMode: 'code', |
|
|
|
|
expr: '', |
|
|
|
|
legendFormat: '__auto', |
|
|
|
|