mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Don't throw error when dealing with other currencies
The app can handle many currencies, and changing the default currency shouldn't break the Styleguide.
This commit is contained in:
parent
5a427964f4
commit
22b0aa512b
2 changed files with 0 additions and 14 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import { has, trimEnd } from 'lodash';
|
||||
import Decimal from 'decimal.js';
|
||||
import { types } from './sdkLoader';
|
||||
import config from '../config';
|
||||
import { subUnitDivisors } from './currencyConfig';
|
||||
|
||||
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
|
||||
|
|
@ -205,9 +204,6 @@ export const convertMoneyToNumber = value => {
|
|||
if (!(value instanceof types.Money)) {
|
||||
throw new Error('Value must be a Money type');
|
||||
}
|
||||
if (value.currency !== config.currency) {
|
||||
throw new Error('Given currency different from marketplace currency');
|
||||
}
|
||||
const subUnitDivisorAsDecimal = convertDivisorToDecimal(unitDivisor(value.currency));
|
||||
let amount;
|
||||
|
||||
|
|
@ -245,9 +241,6 @@ export const formatMoney = (intl, value) => {
|
|||
if (!(value instanceof types.Money)) {
|
||||
throw new Error('Value must be a Money type');
|
||||
}
|
||||
if (value.currency !== config.currency) {
|
||||
throw new Error('Given currency different from marketplace currency');
|
||||
}
|
||||
const valueAsNumber = convertMoneyToNumber(value);
|
||||
|
||||
// See: https://github.com/yahoo/react-intl/wiki/API#formatnumber
|
||||
|
|
|
|||
|
|
@ -238,13 +238,6 @@ describe('currency utils', () => {
|
|||
const value = null;
|
||||
expect(() => formatMoney(intl, value)).toThrowError('Value must be a Money type');
|
||||
});
|
||||
it('complains about mismatching currencies', () => {
|
||||
const intl = null;
|
||||
const value = new types.Money(100, 'EUR');
|
||||
expect(() => formatMoney(intl, value)).toThrowError(
|
||||
'Given currency different from marketplace currency'
|
||||
);
|
||||
});
|
||||
|
||||
// No test for that actual formatting for now. It depends on the
|
||||
// locale, and it doesn't really make sense to test the fake intl
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue