5425 - Introducing support for all Composite Fields Import (#5470)
Adding support for all Composite Fields while using the "import" functionality. This includes: - Currency - Address Edit : - Refactored a lot of types in the spreadsheet import module - Renamed a lot of functions, hooks and types that were not self-explanatory enough --------- Co-authored-by: Charles Bochet <charles@twenty.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
@ -1,35 +1,17 @@
|
||||
import {
|
||||
convertCurrencyMicrosToCurrency,
|
||||
convertCurrencyToCurrencyMicros,
|
||||
} from '~/utils/convert-currency-amount';
|
||||
|
||||
describe('convertCurrencyToCurrencyMicros', () => {
|
||||
it('should return null if currencyAmount is null', () => {
|
||||
expect(convertCurrencyToCurrencyMicros(null)).toBeNull();
|
||||
});
|
||||
|
||||
it('should throw an error if currencyAmount converted to micros is not a whole number', () => {
|
||||
expect(() => convertCurrencyToCurrencyMicros(1.023)).toThrow(
|
||||
'Cannot convert 1.023 to micros',
|
||||
);
|
||||
});
|
||||
convertCurrencyAmountToCurrencyMicros,
|
||||
convertCurrencyMicrosToCurrencyAmount,
|
||||
} from '~/utils/convertCurrencyToCurrencyMicros';
|
||||
|
||||
describe('convertCurrencyAmountToCurrencyMicros', () => {
|
||||
it('should convert currencyAmount to micros', () => {
|
||||
expect(convertCurrencyToCurrencyMicros(1)).toBe(1000000);
|
||||
expect(convertCurrencyToCurrencyMicros(1.5)).toBe(1500000);
|
||||
expect(convertCurrencyAmountToCurrencyMicros(1)).toBe(1000000);
|
||||
expect(convertCurrencyAmountToCurrencyMicros(1.5)).toBe(1500000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('convertCurrencyMicrosToCurrency', () => {
|
||||
it('should return null if currencyAmountMicros is null', () => {
|
||||
expect(convertCurrencyMicrosToCurrency(null)).toBeNull();
|
||||
});
|
||||
|
||||
it('should return null if currencyAmountMicros is undefined', () => {
|
||||
expect(convertCurrencyMicrosToCurrency(undefined)).toBeNull();
|
||||
});
|
||||
|
||||
describe('convertCurrencyMicrosToCurrencyAmount', () => {
|
||||
it('should convert currency micros to currency', () => {
|
||||
expect(convertCurrencyMicrosToCurrency(24000000)).toBe(24);
|
||||
expect(convertCurrencyMicrosToCurrencyAmount(24000000)).toBe(24);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user