-
Notifications
You must be signed in to change notification settings - Fork 10
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
Showing
10 changed files
with
241 additions
and
236 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,20 +1,24 @@ | ||
import getCurrencySymbol from "../getCurrencySymbol"; | ||
import getCurrencySymbol from '../getCurrencySymbol'; | ||
|
||
describe("getCurrencySymbol", () => { | ||
it("should return the correct symbol for a valid currency code", () => { | ||
const currencyCode = "USD"; | ||
const expectedSymbol = "$"; | ||
describe('getCurrencySymbol', () => { | ||
it('should return the correct symbol for a valid currency code', () => { | ||
const currencyCode = 'USD'; | ||
const expectedSymbol = '$'; | ||
const symbol = getCurrencySymbol(currencyCode); | ||
expect(symbol).toBe(expectedSymbol); | ||
}); | ||
|
||
it("should throw Error for an invalid currency code", () => { | ||
const currencyCode = "XYZ"; // An invalid code | ||
expect(() => getCurrencySymbol(currencyCode)).toThrow("Invalid currencyCode!"); | ||
it('should throw Error for an invalid currency code', () => { | ||
const currencyCode = 'XYZ'; // An invalid code | ||
expect(() => getCurrencySymbol(currencyCode)).toThrow( | ||
'Invalid currencyCode!', | ||
); | ||
}); | ||
|
||
it("should throw Error for an empty string", () => { | ||
const currencyCode = ""; | ||
expect(() => getCurrencySymbol(currencyCode)).toThrow("Invalid currencyCode!"); | ||
it('should throw Error for an empty string', () => { | ||
const currencyCode = ''; | ||
expect(() => getCurrencySymbol(currencyCode)).toThrow( | ||
'Invalid currencyCode!', | ||
); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,97 +1,97 @@ | ||
export const CURRENCIES: { [key: string]: {symbol:string, name: string} } = { | ||
AED: { symbol: "د.إ", name: "United Arab Emirates Dirham" }, | ||
ALL: { symbol: "Lek", name: "Albanian Lek" }, | ||
AMD: { symbol: "֏", name: "Armenian Dram" }, | ||
ARS: { symbol: "ARS", name: "Argentine Peso" }, | ||
AUD: { symbol: "A$", name: "Australian Dollar" }, | ||
AWG: { symbol: "Afl.", name: "Aruban Florin" }, | ||
BBD: { symbol: "$", name: "Barbadian Dollar" }, | ||
BDT: { symbol: "৳", name: "Bangladeshi Taka" }, | ||
BMD: { symbol: "$", name: "Bermudian Dollar" }, | ||
BND: { symbol: "BND", name: "Brunei Dollar" }, | ||
BOB: { symbol: "Bs", name: "Bolivian Boliviano" }, | ||
BSD: { symbol: "B$", name: "Bahamian Dollar" }, | ||
BWP: { symbol: "P", name: "Botswanan Pula" }, | ||
BZD: { symbol: "BZ$", name: "Belize Dollar" }, | ||
CAD: { symbol: "C$", name: "Canadian Dollar" }, | ||
CHF: { symbol: "CHf", name: "Swiss Franc" }, | ||
CNY: { symbol: "¥", name: "Chinese Yuan" }, | ||
COP: { symbol: "COL$", name: "Colombian Peso" }, | ||
CRC: { symbol: "₡", name: "Costa Rican Colón" }, | ||
CUP: { symbol: "$MN", name: "Cuban Peso" }, | ||
CZK: { symbol: "Kč", name: "Czech Koruna" }, | ||
DKK: { symbol: "DKK", name: "Danish Krone" }, | ||
DOP: { symbol: "RD$", name: "Dominican Peso" }, | ||
DZD: { symbol: "د.ج", name: "Algerian Dinar" }, | ||
EGP: { symbol: "E£", name: "Egyptian Pound" }, | ||
ETB: { symbol: "ብር", name: "Ethiopian Birr" }, | ||
EUR: { symbol: "€", name: "Euro" }, | ||
FJD: { symbol: "FJ$", name: "Fijian Dollar" }, | ||
GBP: { symbol: "£", name: "British Pound" }, | ||
GHS: { symbol: "GH₵", name: "Ghanaian Cedi" }, | ||
GIP: { symbol: "GIP", name: "Gibraltar Pound" }, | ||
GMD: { symbol: "D", name: "Gambian Dalasi" }, | ||
GTQ: { symbol: "Q", name: "Guatemalan Quetzal" }, | ||
GYD: { symbol: "G$", name: "Guyanese Dollar" }, | ||
HKD: { symbol: "HK$", name: "Hong Kong Dollar" }, | ||
HNL: { symbol: "HNL", name: "Honduran Lempira" }, | ||
HRK: { symbol: "kn", name: "Croatian Kuna" }, | ||
HTG: { symbol: "G", name: "Haitian Gourde" }, | ||
HUF: { symbol: "Ft", name: "Hungarian Forint" }, | ||
IDR: { symbol: "Rp", name: "Indonesian Rupiah" }, | ||
ILS: { symbol: "₪", name: "Israeli New Shekel" }, | ||
INR: { symbol: "₹", name: "Indian Rupee" }, | ||
JMD: { symbol: "J$", name: "Jamaican Dollar" }, | ||
KES: { symbol: "Ksh", name: "Kenyan Shilling" }, | ||
KGS: { symbol: "Лв", name: "Kyrgystani Som" }, | ||
KHR: { symbol: "៛", name: "Cambodian Riel" }, | ||
KYD: { symbol: "CI$", name: "Cayman Islands Dollar" }, | ||
KZT: { symbol: "₸", name: "Kazakhstani Tenge" }, | ||
LAK: { symbol: "₭", name: "Laotian Kip" }, | ||
LKR: { symbol: "රු", name: "Sri Lankan Rupee" }, | ||
LRD: { symbol: "L$", name: "Liberian Dollar" }, | ||
LSL: { symbol: "LSL", name: "Lesotho Loti" }, | ||
MAD: { symbol: "د.م.", name: "Moroccan Dirham" }, | ||
MDL: { symbol: "MDL", name: "Moldovan Leu" }, | ||
MKD: { symbol: "ден", name: "Macedonian Denar" }, | ||
MMK: { symbol: "MMK", name: "Myanmar Kyat" }, | ||
MNT: { symbol: "₮", name: "Mongolian Tugrik" }, | ||
MOP: { symbol: "MOP$", name: "Macanese Pataca" }, | ||
MUR: { symbol: "₨", name: "Mauritian Rupee" }, | ||
MVR: { symbol: "Rf", name: "Maldivian Rufiyaa" }, | ||
MWK: { symbol: "MK", name: "Malawian Kwacha" }, | ||
MXN: { symbol: "Mex$", name: "Mexican Peso" }, | ||
MYR: { symbol: "RM", name: "Malaysian Ringgit" }, | ||
NAD: { symbol: "N$", name: "Namibian Dollar" }, | ||
NGN: { symbol: "₦", name: "Nigerian Naira" }, | ||
NIO: { symbol: "NIO", name: "Nicaraguan Córdoba" }, | ||
NOK: { symbol: "NOK", name: "Norwegian Krone" }, | ||
NPR: { symbol: "रू", name: "Nepalese Rupee" }, | ||
NZD: { symbol: "NZ$", name: "New Zealand Dollar" }, | ||
PEN: { symbol: "S/", name: "Peruvian Nuevo Sol" }, | ||
PGK: { symbol: "PGK", name: "Papua New Guinean Kina" }, | ||
PHP: { symbol: "₱", name: "Philippine Peso" }, | ||
PKR: { symbol: "₨", name: "Pakistani Rupee" }, | ||
QAR: { symbol: "QR", name: "Qatari Riyal" }, | ||
RUB: { symbol: "₽", name: "Russian Ruble" }, | ||
SAR: { symbol: "SR", name: "Saudi Riyal" }, | ||
SCR: { symbol: "SRe", name: "Seychellois Rupee" }, | ||
SEK: { symbol: "SEK", name: "Swedish Krona" }, | ||
SGD: { symbol: "S$", name: "Singapore Dollar" }, | ||
SLL: { symbol: "Le", name: "Sierra Leonean Leone" }, | ||
SOS: { symbol: "Sh.so.", name: "Somali Shilling" }, | ||
SSP: { symbol: "SS£", name: "South Sudanese Pound" }, | ||
SVC: { symbol: "₡", name: "Salvadoran Colón" }, | ||
SZL: { symbol: "E", name: "Swazi Lilangeni" }, | ||
THB: { symbol: "฿", name: "Thai Baht" }, | ||
TTD: { symbol: "TT$", name: "Trinidad and Tobago Dollar" }, | ||
TZS: { symbol: "Sh", name: "Tanzanian Shilling" }, | ||
USD: { symbol: "$", name: "United States Dollar" }, | ||
UYU: { symbol: "$U", name: "Uruguayan Peso" }, | ||
UZS: { symbol: "so'm", name: "Uzbekistani Som" }, | ||
YER: { symbol: "﷼", name: "Yemeni Rial" }, | ||
ZAR: { symbol: "R", name: "South African Rand" }, | ||
KWD: { symbol: "د.ك", name: "Kuwaiti Dinar" }, | ||
BHD: { symbol: "د.ب.", name: "Bahraini Dinar" }, | ||
OMR: { symbol: "ر.ع.", name: "Omani Rial" }, | ||
export const CURRENCIES: { [key: string]: { symbol: string; name: string } } = { | ||
AED: { symbol: 'د.إ', name: 'United Arab Emirates Dirham' }, | ||
ALL: { symbol: 'Lek', name: 'Albanian Lek' }, | ||
AMD: { symbol: '֏', name: 'Armenian Dram' }, | ||
ARS: { symbol: 'ARS', name: 'Argentine Peso' }, | ||
AUD: { symbol: 'A$', name: 'Australian Dollar' }, | ||
AWG: { symbol: 'Afl.', name: 'Aruban Florin' }, | ||
BBD: { symbol: '$', name: 'Barbadian Dollar' }, | ||
BDT: { symbol: '৳', name: 'Bangladeshi Taka' }, | ||
BMD: { symbol: '$', name: 'Bermudian Dollar' }, | ||
BND: { symbol: 'BND', name: 'Brunei Dollar' }, | ||
BOB: { symbol: 'Bs', name: 'Bolivian Boliviano' }, | ||
BSD: { symbol: 'B$', name: 'Bahamian Dollar' }, | ||
BWP: { symbol: 'P', name: 'Botswanan Pula' }, | ||
BZD: { symbol: 'BZ$', name: 'Belize Dollar' }, | ||
CAD: { symbol: 'C$', name: 'Canadian Dollar' }, | ||
CHF: { symbol: 'CHf', name: 'Swiss Franc' }, | ||
CNY: { symbol: '¥', name: 'Chinese Yuan' }, | ||
COP: { symbol: 'COL$', name: 'Colombian Peso' }, | ||
CRC: { symbol: '₡', name: 'Costa Rican Colón' }, | ||
CUP: { symbol: '$MN', name: 'Cuban Peso' }, | ||
CZK: { symbol: 'Kč', name: 'Czech Koruna' }, | ||
DKK: { symbol: 'DKK', name: 'Danish Krone' }, | ||
DOP: { symbol: 'RD$', name: 'Dominican Peso' }, | ||
DZD: { symbol: 'د.ج', name: 'Algerian Dinar' }, | ||
EGP: { symbol: 'E£', name: 'Egyptian Pound' }, | ||
ETB: { symbol: 'ብር', name: 'Ethiopian Birr' }, | ||
EUR: { symbol: '€', name: 'Euro' }, | ||
FJD: { symbol: 'FJ$', name: 'Fijian Dollar' }, | ||
GBP: { symbol: '£', name: 'British Pound' }, | ||
GHS: { symbol: 'GH₵', name: 'Ghanaian Cedi' }, | ||
GIP: { symbol: 'GIP', name: 'Gibraltar Pound' }, | ||
GMD: { symbol: 'D', name: 'Gambian Dalasi' }, | ||
GTQ: { symbol: 'Q', name: 'Guatemalan Quetzal' }, | ||
GYD: { symbol: 'G$', name: 'Guyanese Dollar' }, | ||
HKD: { symbol: 'HK$', name: 'Hong Kong Dollar' }, | ||
HNL: { symbol: 'HNL', name: 'Honduran Lempira' }, | ||
HRK: { symbol: 'kn', name: 'Croatian Kuna' }, | ||
HTG: { symbol: 'G', name: 'Haitian Gourde' }, | ||
HUF: { symbol: 'Ft', name: 'Hungarian Forint' }, | ||
IDR: { symbol: 'Rp', name: 'Indonesian Rupiah' }, | ||
ILS: { symbol: '₪', name: 'Israeli New Shekel' }, | ||
INR: { symbol: '₹', name: 'Indian Rupee' }, | ||
JMD: { symbol: 'J$', name: 'Jamaican Dollar' }, | ||
KES: { symbol: 'Ksh', name: 'Kenyan Shilling' }, | ||
KGS: { symbol: 'Лв', name: 'Kyrgystani Som' }, | ||
KHR: { symbol: '៛', name: 'Cambodian Riel' }, | ||
KYD: { symbol: 'CI$', name: 'Cayman Islands Dollar' }, | ||
KZT: { symbol: '₸', name: 'Kazakhstani Tenge' }, | ||
LAK: { symbol: '₭', name: 'Laotian Kip' }, | ||
LKR: { symbol: 'රු', name: 'Sri Lankan Rupee' }, | ||
LRD: { symbol: 'L$', name: 'Liberian Dollar' }, | ||
LSL: { symbol: 'LSL', name: 'Lesotho Loti' }, | ||
MAD: { symbol: 'د.م.', name: 'Moroccan Dirham' }, | ||
MDL: { symbol: 'MDL', name: 'Moldovan Leu' }, | ||
MKD: { symbol: 'ден', name: 'Macedonian Denar' }, | ||
MMK: { symbol: 'MMK', name: 'Myanmar Kyat' }, | ||
MNT: { symbol: '₮', name: 'Mongolian Tugrik' }, | ||
MOP: { symbol: 'MOP$', name: 'Macanese Pataca' }, | ||
MUR: { symbol: '₨', name: 'Mauritian Rupee' }, | ||
MVR: { symbol: 'Rf', name: 'Maldivian Rufiyaa' }, | ||
MWK: { symbol: 'MK', name: 'Malawian Kwacha' }, | ||
MXN: { symbol: 'Mex$', name: 'Mexican Peso' }, | ||
MYR: { symbol: 'RM', name: 'Malaysian Ringgit' }, | ||
NAD: { symbol: 'N$', name: 'Namibian Dollar' }, | ||
NGN: { symbol: '₦', name: 'Nigerian Naira' }, | ||
NIO: { symbol: 'NIO', name: 'Nicaraguan Córdoba' }, | ||
NOK: { symbol: 'NOK', name: 'Norwegian Krone' }, | ||
NPR: { symbol: 'रू', name: 'Nepalese Rupee' }, | ||
NZD: { symbol: 'NZ$', name: 'New Zealand Dollar' }, | ||
PEN: { symbol: 'S/', name: 'Peruvian Nuevo Sol' }, | ||
PGK: { symbol: 'PGK', name: 'Papua New Guinean Kina' }, | ||
PHP: { symbol: '₱', name: 'Philippine Peso' }, | ||
PKR: { symbol: '₨', name: 'Pakistani Rupee' }, | ||
QAR: { symbol: 'QR', name: 'Qatari Riyal' }, | ||
RUB: { symbol: '₽', name: 'Russian Ruble' }, | ||
SAR: { symbol: 'SR', name: 'Saudi Riyal' }, | ||
SCR: { symbol: 'SRe', name: 'Seychellois Rupee' }, | ||
SEK: { symbol: 'SEK', name: 'Swedish Krona' }, | ||
SGD: { symbol: 'S$', name: 'Singapore Dollar' }, | ||
SLL: { symbol: 'Le', name: 'Sierra Leonean Leone' }, | ||
SOS: { symbol: 'Sh.so.', name: 'Somali Shilling' }, | ||
SSP: { symbol: 'SS£', name: 'South Sudanese Pound' }, | ||
SVC: { symbol: '₡', name: 'Salvadoran Colón' }, | ||
SZL: { symbol: 'E', name: 'Swazi Lilangeni' }, | ||
THB: { symbol: '฿', name: 'Thai Baht' }, | ||
TTD: { symbol: 'TT$', name: 'Trinidad and Tobago Dollar' }, | ||
TZS: { symbol: 'Sh', name: 'Tanzanian Shilling' }, | ||
USD: { symbol: '$', name: 'United States Dollar' }, | ||
UYU: { symbol: '$U', name: 'Uruguayan Peso' }, | ||
UZS: { symbol: "so'm", name: 'Uzbekistani Som' }, | ||
YER: { symbol: '﷼', name: 'Yemeni Rial' }, | ||
ZAR: { symbol: 'R', name: 'South African Rand' }, | ||
KWD: { symbol: 'د.ك', name: 'Kuwaiti Dinar' }, | ||
BHD: { symbol: 'د.ب.', name: 'Bahraini Dinar' }, | ||
OMR: { symbol: 'ر.ع.', name: 'Omani Rial' }, | ||
}; |
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
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
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { CURRENCIES } from "./data/currencies"; | ||
import { withErrorBoundary } from "../../common/errorBoundary"; | ||
import { CURRENCIES } from './data/currencies'; | ||
import { withErrorBoundary } from '../../common/errorBoundary'; | ||
|
||
const getCurrencySymbol = (currencyCode: keyof typeof CURRENCIES): string => { | ||
if (currencyCode in CURRENCIES) return CURRENCIES[currencyCode]?.symbol; | ||
else throw new Error("Invalid currencyCode!"); | ||
else throw new Error('Invalid currencyCode!'); | ||
}; | ||
|
||
export default withErrorBoundary(getCurrencySymbol); |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { default as formatNumber } from "./formatNumber"; | ||
export { default as getCurrencyList } from "./getCurrencyList"; | ||
export { default as getCurrencySymbol } from "./getCurrencySymbol"; | ||
export { default as formatAmountByParts } from "./formatAmountByParts"; | ||
export { default as formatNumber } from './formatNumber'; | ||
export { default as getCurrencyList } from './getCurrencyList'; | ||
export { default as getCurrencySymbol } from './getCurrencySymbol'; | ||
export { default as formatAmountByParts } from './formatAmountByParts'; |
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
Oops, something went wrong.