forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6906dd
commit 08b9fec
Showing
3 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
packages/utils/src/__tests__/getWalletCurrencyIcon.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import getWalletCurrencyIcon from '../getWalletCurrencyIcon'; | ||
|
||
describe('getWalletCurrencyIcon', () => { | ||
describe('Should return proper icons for cashier modal', () => { | ||
it('should return proper icon for demo currency', () => { | ||
expect(getWalletCurrencyIcon('demo', false, true)).toBe('IcWalletDerivDemoLight'); | ||
}); | ||
|
||
it('should return proper icon for USDT, eUSDT, tUSDT, UST currency in dark mode', () => { | ||
const currencies = ['USDT', 'eUSDT', 'tUSDT', 'UST']; | ||
currencies.forEach(currency => { | ||
expect(getWalletCurrencyIcon(currency, true, true)).toBe('IcWalletModalTetherDark'); | ||
}); | ||
}); | ||
|
||
it('should return proper icon for USDT, eUSDT, tUSDT, UST currency in light mode', () => { | ||
const currencies = ['USDT', 'eUSDT', 'tUSDT', 'UST']; | ||
currencies.forEach(currency => { | ||
expect(getWalletCurrencyIcon(currency, false, true)).toBe('IcWalletModalTetherLight'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Should return proper icons for other components', () => { | ||
it('should return proper icon for demo currency in dark mode', () => { | ||
expect(getWalletCurrencyIcon('demo', false)).toBe('IcWalletDerivDemoLight'); | ||
}); | ||
|
||
it('should return proper icon for demo currency in light mode', () => { | ||
expect(getWalletCurrencyIcon('demo', true)).toBe('IcWalletDerivDemoDark'); | ||
}); | ||
|
||
it('should return proper icon for USD currency in dark/light mode', () => { | ||
expect(getWalletCurrencyIcon('USD')).toBe('IcWalletCurrencyUsd'); | ||
}); | ||
|
||
it('should return proper icon for EUR currency in dark/light mode', () => { | ||
expect(getWalletCurrencyIcon('EUR')).toBe('IcWalletCurrencyEur'); | ||
}); | ||
|
||
it('should return proper icon for AUD currency in dark/light mode', () => { | ||
expect(getWalletCurrencyIcon('AUD')).toBe('IcWalletCurrencyAud'); | ||
}); | ||
|
||
it('should return proper icon for GBP currency in dark/light mode', () => { | ||
expect(getWalletCurrencyIcon('GBP')).toBe('IcWalletCurrencyGbp'); | ||
}); | ||
|
||
it('should return proper icon for BTC currency in dark mode', () => { | ||
expect(getWalletCurrencyIcon('BTC', false)).toBe('IcWalletBitcoinLight'); | ||
}); | ||
|
||
it('should return proper icon for BTC currency in light mode', () => { | ||
expect(getWalletCurrencyIcon('BTC', true)).toBe('IcWalletBitcoinDark'); | ||
}); | ||
|
||
it('should return proper icon for ETH currency in dark mode', () => { | ||
expect(getWalletCurrencyIcon('ETH', false)).toBe('IcWalletEtheriumLight'); | ||
}); | ||
|
||
it('should return proper icon for ETH currency in light mode', () => { | ||
expect(getWalletCurrencyIcon('ETH', true)).toBe('IcWalletEtheriumDark'); | ||
}); | ||
|
||
it('should return proper icon for USDT, eUSDT, tUSDT, UST currency in dark mode', () => { | ||
const currencies = ['USDT', 'eUSDT', 'tUSDT', 'UST']; | ||
currencies.forEach(currency => { | ||
expect(getWalletCurrencyIcon(currency, true)).toBe('IcWalletTetherDark'); | ||
}); | ||
}); | ||
|
||
it('should return proper icon for USDT, eUSDT, tUSDT, UST currency in light mode', () => { | ||
const currencies = ['USDT', 'eUSDT', 'tUSDT', 'UST']; | ||
currencies.forEach(currency => { | ||
expect(getWalletCurrencyIcon(currency, false)).toBe('IcWalletTetherLight'); | ||
}); | ||
}); | ||
|
||
it('should return proper icon for LTC currency in dark mode', () => { | ||
expect(getWalletCurrencyIcon('LTC', false)).toBe('IcWalletLiteCoinLight'); | ||
}); | ||
|
||
it('should return proper icon for LTC currency in light mode', () => { | ||
expect(getWalletCurrencyIcon('LTC', true)).toBe('IcWalletLiteCoinDark'); | ||
}); | ||
|
||
it('should return proper icon for USDC currency in dark mode', () => { | ||
expect(getWalletCurrencyIcon('USDC', false)).toBe('IcWalletUsdCoinLight'); | ||
}); | ||
|
||
it('should return proper icon for USDC currency in light mode', () => { | ||
expect(getWalletCurrencyIcon('USDC', true)).toBe('IcWalletUsdCoinDark'); | ||
}); | ||
}); | ||
}); |
33 changes: 33 additions & 0 deletions
33
packages/utils/src/__tests__/groupTransactionsByDay.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import groupTransactionsByDay from '../groupTransactionsByDay'; | ||
import { Statement } from '@deriv/api-types'; | ||
|
||
describe('groupTransactionsByDay', () => { | ||
it('should group transactions by day', () => { | ||
const transactions: Statement['transactions'] = [ | ||
{ | ||
transaction_time: new Date('08 Jun 2023').getTime() / 1000, | ||
}, | ||
{ | ||
transaction_time: new Date('10 Jun 2023').getTime() / 1000, | ||
}, | ||
{ | ||
transaction_time: new Date('12 Jun 2023').getTime() / 1000, | ||
}, | ||
{ | ||
transaction_time: new Date('08 Jun 2023').getTime() / 1000, | ||
}, | ||
{ | ||
transaction_time: new Date('10 Jun 2023').getTime() / 1000, | ||
}, | ||
{ | ||
transaction_time: new Date('12 Jun 2023').getTime() / 1000, | ||
}, | ||
]; | ||
|
||
const groupped_transactions = groupTransactionsByDay(transactions); | ||
|
||
expect(transactions.length).toBe(6); | ||
expect(Object.keys(groupped_transactions).length).toBe(3); | ||
expect(Object.keys(groupped_transactions)).toStrictEqual(['08 Jun 2023', '10 Jun 2023', '12 Jun 2023']); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters