Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
features
/
variables
/
constant
/
File Content:
actions.test.ts
import { reduxTester } from '../../../../test/core/redux/reduxTester'; import { variableAdapters } from '../adapters'; import { getRootReducer, RootReducerType } from '../state/helpers'; import { toKeyedAction } from '../state/keyedVariablesReducer'; import { addVariable, setCurrentVariableValue } from '../state/sharedReducer'; import { ConstantVariableModel, initialVariableModelState, VariableOption } from '../types'; import { toKeyedVariableIdentifier, toVariablePayload } from '../utils'; import { updateConstantVariableOptions } from './actions'; import { createConstantVariableAdapter } from './adapter'; import { createConstantOptionsFromQuery } from './reducer'; describe('constant actions', () => { variableAdapters.setInit(() => [createConstantVariableAdapter()]); describe('when updateConstantVariableOptions is dispatched', () => { it('then correct actions are dispatched', async () => { const option: VariableOption = { value: 'A', text: 'A', selected: false, }; const variable: ConstantVariableModel = { ...initialVariableModelState, id: '0', rootStateKey: 'key', index: 0, type: 'constant', name: 'Constant', current: { value: '', text: '', selected: false, }, options: [], query: 'A', }; const tester = await reduxTester<RootReducerType>() .givenRootReducer(getRootReducer()) .whenActionIsDispatched( toKeyedAction('key', addVariable(toVariablePayload(variable, { global: false, index: 0, model: variable }))) ) .whenAsyncActionIsDispatched(updateConstantVariableOptions(toKeyedVariableIdentifier(variable)), true); tester.thenDispatchedActionsShouldEqual( toKeyedAction('key', createConstantOptionsFromQuery(toVariablePayload(variable))), toKeyedAction('key', setCurrentVariableValue(toVariablePayload(variable, { option }))) ); }); }); });
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
ConstantVariableEditor.tsx
748 bytes
0644
actions.test.ts
2015 bytes
0644
actions.ts
702 bytes
0644
adapter.ts
2027 bytes
0644
reducer.test.ts
2233 bytes
0644
reducer.ts
1234 bytes
0644
N4ST4R_ID | Naxtarrr