mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* 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>
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import { reducerTester } from '../../../../test/core/redux/reducerTester';
|
|
import {
|
|
initialTransactionState,
|
|
transactionReducer,
|
|
TransactionState,
|
|
TransactionStatus,
|
|
variablesClearTransaction,
|
|
variablesCompleteTransaction,
|
|
variablesInitTransaction,
|
|
} from './transactionReducer';
|
|
|
|
describe('transactionReducer', () => {
|
|
describe('when variablesInitTransaction is dispatched', () => {
|
|
it('then state should be correct', () => {
|
|
reducerTester<TransactionState>()
|
|
.givenReducer(transactionReducer, { ...initialTransactionState })
|
|
.whenActionIsDispatched(variablesInitTransaction({ uid: 'a uid' }))
|
|
.thenStateShouldEqual({ ...initialTransactionState, uid: 'a uid', status: TransactionStatus.Fetching });
|
|
});
|
|
});
|
|
|
|
describe('when variablesCompleteTransaction is dispatched', () => {
|
|
describe('and transaction uid is the same', () => {
|
|
it('then state should be correct', () => {
|
|
reducerTester<TransactionState>()
|
|
.givenReducer(transactionReducer, {
|
|
...initialTransactionState,
|
|
uid: 'before',
|
|
status: TransactionStatus.Fetching,
|
|
})
|
|
.whenActionIsDispatched(variablesCompleteTransaction({ uid: 'before' }))
|
|
.thenStateShouldEqual({ ...initialTransactionState, uid: 'before', status: TransactionStatus.Completed });
|
|
});
|
|
});
|
|
|
|
describe('and transaction uid is not the same', () => {
|
|
it('then state should be correct', () => {
|
|
reducerTester<TransactionState>()
|
|
.givenReducer(transactionReducer, {
|
|
...initialTransactionState,
|
|
uid: 'before',
|
|
status: TransactionStatus.Fetching,
|
|
})
|
|
.whenActionIsDispatched(variablesCompleteTransaction({ uid: 'after' }))
|
|
.thenStateShouldEqual({ ...initialTransactionState, uid: 'before', status: TransactionStatus.Fetching });
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('when variablesClearTransaction is dispatched', () => {
|
|
it('then state should be correct', () => {
|
|
reducerTester<TransactionState>()
|
|
.givenReducer(transactionReducer, {
|
|
...initialTransactionState,
|
|
uid: 'before',
|
|
status: TransactionStatus.Completed,
|
|
})
|
|
.whenActionIsDispatched(variablesClearTransaction())
|
|
.thenStateShouldEqual({ ...initialTransactionState });
|
|
});
|
|
});
|
|
});
|