Elasticsearch: Migrate queryeditor to React (#28033)

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
Giordano Ricci
2020-12-04 14:29:40 +00:00
committed by GitHub
parent 3d6380a0aa
commit bb45f5fedc
76 changed files with 4364 additions and 1924 deletions

View File

@ -0,0 +1,43 @@
import { reducerTester } from 'test/core/redux/reducerTester';
import { ElasticsearchQuery } from '../../types';
import { aliasPatternReducer, changeAliasPattern, changeQuery, queryReducer } from './state';
describe('Query Reducer', () => {
it('Should correctly set `query`', () => {
const expectedQuery: ElasticsearchQuery['query'] = 'Some lucene query';
reducerTester()
.givenReducer(queryReducer, '')
.whenActionIsDispatched(changeQuery(expectedQuery))
.thenStateShouldEqual(expectedQuery);
});
it('Should not change state with other action types', () => {
const initialState: ElasticsearchQuery['query'] = 'Some lucene query';
reducerTester()
.givenReducer(queryReducer, initialState)
.whenActionIsDispatched({ type: 'THIS ACTION SHOULD NOT HAVE ANY EFFECT IN THIS REDUCER' })
.thenStateShouldEqual(initialState);
});
});
describe('Alias Pattern Reducer', () => {
it('Should correctly set `alias`', () => {
const expectedAlias: ElasticsearchQuery['alias'] = 'Some alias pattern';
reducerTester()
.givenReducer(aliasPatternReducer, '')
.whenActionIsDispatched(changeAliasPattern(expectedAlias))
.thenStateShouldEqual(expectedAlias);
});
it('Should not change state with other action types', () => {
const initialState: ElasticsearchQuery['alias'] = 'Some alias pattern';
reducerTester()
.givenReducer(aliasPatternReducer, initialState)
.whenActionIsDispatched({ type: 'THIS ACTION SHOULD NOT HAVE ANY EFFECT IN THIS REDUCER' })
.thenStateShouldEqual(initialState);
});
});