Files
Hugo Häggmark 3c1f27b0e6 Chore: reduce strict errors for variables (#31241)
* Chore: reduces a lot of variable errors

* Chore: reduces variable Editor errors

* Chore: reduces variable Picker errors

* Chore: reduce error count

* Chore: reduces errors for ChangeEvent instead of FormEvent

* Chore: reduces errors with CombinedState

* Chore: reduces ComponentType errors

* Chore: reduce errors in reducers

* Chore: reduces misc errors

* Chore: reduce AdhocPicker errors

* Chore: reduce error limit

* Update public/app/features/variables/adhoc/picker/AdHocFilterValue.tsx

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

* Chore: updates after PR comments

* Chore: small refactor

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-02-18 06:21:35 +01:00

62 lines
2.0 KiB
TypeScript

import { variableAdapters } from '../adapters';
import { updateCustomVariableOptions } from './actions';
import { createCustomVariableAdapter } from './adapter';
import { reduxTester } from '../../../../test/core/redux/reduxTester';
import { getRootReducer, RootReducerType } from '../state/helpers';
import { CustomVariableModel, initialVariableModelState, VariableOption } from '../types';
import { toVariablePayload } from '../state/types';
import { addVariable, setCurrentVariableValue } from '../state/sharedReducer';
import { createCustomOptionsFromQuery } from './reducer';
describe('custom actions', () => {
variableAdapters.setInit(() => [createCustomVariableAdapter()]);
describe('when updateCustomVariableOptions is dispatched', () => {
it('then correct actions are dispatched', async () => {
const option: VariableOption = {
value: 'A',
text: 'A',
selected: false,
};
const variable: CustomVariableModel = {
...initialVariableModelState,
id: '0',
index: 0,
type: 'custom',
name: 'Custom',
current: {
value: '',
text: '',
selected: false,
},
options: [
{
text: 'A',
value: 'A',
selected: false,
},
{
text: 'B',
value: 'B',
selected: false,
},
],
query: 'A,B',
multi: true,
includeAll: false,
};
const tester = await reduxTester<RootReducerType>()
.givenRootReducer(getRootReducer())
.whenActionIsDispatched(addVariable(toVariablePayload(variable, { global: false, index: 0, model: variable })))
.whenAsyncActionIsDispatched(updateCustomVariableOptions(toVariablePayload(variable)), true);
tester.thenDispatchedActionsShouldEqual(
createCustomOptionsFromQuery(toVariablePayload(variable)),
setCurrentVariableValue(toVariablePayload(variable, { option }))
);
});
});
});