Daniel Ternyak a61dc268dc Add reducer tests (#133)
* create config reducer tests

* create generateWallet reducer tests

* create wallet reducer tests

* create swap reducer tests; use empty string as destination amount when origin amount is an empty string instead of 0

* add additional swap reducer tests

* refactor swap; additional tests

* create separate dir for swap reducer
2017-08-24 10:53:59 +02:00

37 lines
904 B
JavaScript

import { combineAndUpper } from 'utils/formatters';
import without from 'lodash/without';
import { ALL_CRYPTO_KIND_OPTIONS } from '.';
export const buildDestinationAmount = (
originAmount,
originKind,
destinationKind,
bityRates
) => {
let pairName = combineAndUpper(originKind, destinationKind);
let bityRate = bityRates[pairName];
return originAmount !== null ? originAmount * bityRate : null;
};
export const buildDestinationKind = (
originKind: string,
destinationKind: string
): string => {
if (originKind === destinationKind) {
return without(ALL_CRYPTO_KIND_OPTIONS, originKind)[0];
} else {
return destinationKind;
}
};
export const buildOriginKind = (
originKind: string,
destinationKind: string
): string => {
if (originKind === destinationKind) {
return without(ALL_CRYPTO_KIND_OPTIONS, destinationKind)[0];
} else {
return originKind;
}
};