@yoroi/claim
Version:
The Claim (proof-of-onboarding) package of Yoroi SDK
57 lines (56 loc) • 1.93 kB
JavaScript
;
var _manager = require("../../../manager.mocks");
var _state = require("./state");
describe('claimReducer', () => {
it('should return default state when no action matches', () => {
const initialState = _state.defaultClaimState;
const action = {
type: 'unknown'
};
const newState = (0, _state.claimReducer)(initialState, action);
expect(newState).toBe(initialState);
});
it('should handle ClaimInfoChanged action', () => {
const initialState = _state.defaultClaimState;
const action = {
type: _state.ClaimActionType.ClaimInfoChanged,
claimInfo: _manager.claimApiMockResponses.claimTokens.accepted
};
const newState = (0, _state.claimReducer)(initialState, action);
expect(newState.claimInfo).toEqual(_manager.claimApiMockResponses.claimTokens.accepted);
});
it('should handle ScanActionClaimChanged action', () => {
const initialState = _state.defaultClaimState;
const scanAction = {
action: 'claim',
code: 'code',
params: {},
url: 'https://example.com'
};
const action = {
type: _state.ClaimActionType.ScanActionClaimChanged,
scanActionClaim: scanAction
};
const newState = (0, _state.claimReducer)(initialState, action);
expect(newState.scanActionClaim).toEqual(scanAction);
});
it('should handle Reset action', () => {
const scanAction = {
action: 'claim',
code: 'code',
params: {},
url: 'https://example.com'
};
const populatedState = {
claimInfo: _manager.claimApiMockResponses.claimTokens.accepted,
scanActionClaim: scanAction
};
const action = {
type: _state.ClaimActionType.Reset
};
const newState = (0, _state.claimReducer)(populatedState, action);
expect(newState.claimInfo).toBeUndefined();
expect(newState.scanActionClaim).toBeUndefined();
});
});
//# sourceMappingURL=state.test.js.map