state.test.ts 728 B

12345678910111213141516171819202122
  1. import { QueryEditorMode } from '../../prometheus/querybuilder/shared/types';
  2. import { changeEditorMode, getQueryWithDefaults } from './state';
  3. describe('getQueryWithDefaults(', () => {
  4. it('should set defaults', () => {
  5. expect(getQueryWithDefaults({ refId: 'A' } as any)).toEqual({
  6. editorMode: 'builder',
  7. expr: '',
  8. queryType: 'range',
  9. refId: 'A',
  10. });
  11. });
  12. it('changing editor mode with blank query should change default', () => {
  13. changeEditorMode({ refId: 'A', expr: '' }, QueryEditorMode.Code, (query) => {
  14. expect(query.editorMode).toBe(QueryEditorMode.Code);
  15. });
  16. expect(getQueryWithDefaults({ refId: 'A' } as any).editorMode).toEqual(QueryEditorMode.Code);
  17. });
  18. });