Add tests for toCurrency
This commit is contained in:
@ -2871,8 +2871,8 @@ Take a number and return specified currency formatting.
|
||||
Use \`Intl.NumberFormat\` to enable country / currency sensitive formatting.
|
||||
|
||||
`,
|
||||
'comments': [`// €123,456.79 | currency: Euro | currencyLangFormat: Local`,`// €123,456.79 | currency: US Dollar | currencyLangFormat: English (United States)`,`// ۱۲۳٬۴۵۶٫۷۹ $ | currency: US Dollar | currencyLangFormat: Farsi`,`// ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local`,`// 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish`],
|
||||
'hash': 'd1c86c6f075b79b53b74aede9669101f1a07e89cc73ccabf347ad42674b1a33c'
|
||||
'comments': [`// €123,456.79 | currency: Euro | currencyLangFormat: Local`,`// $123,456.79 | currency: US Dollar | currencyLangFormat: English (United States)`,`// ۱۲۳٬۴۵۶٫۷۹ $ | currency: US Dollar | currencyLangFormat: Farsi`,`// ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local`,`// 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish`],
|
||||
'hash': 'f00f4a2229ed6b9f98356e6b0ea9e245f1d53bdbd616eb4c2babb87d7cf350b9'
|
||||
},
|
||||
'toDecimalMark' : {
|
||||
'description': `### toDecimalMark
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
Thu Feb 08 2018 14:34:19 GMT+0200 (GTB Standard Time)
|
||||
Hash changes: 0
|
||||
Thu Feb 08 2018 16:08:52 GMT+0200 (GTB Standard Time)
|
||||
Hash changes: 1
|
||||
|
||||
Snippet name:toCurrency
|
||||
Old hash: d1c86c6f075b79b53b74aede9669101f1a07e89cc73ccabf347ad42674b1a33c
|
||||
New hash: f00f4a2229ed6b9f98356e6b0ea9e245f1d53bdbd616eb4c2babb87d7cf350b9
|
||||
|
||||
@ -2871,8 +2871,8 @@ Take a number and return specified currency formatting.
|
||||
Χρησιμοποιείται \`Intl.NumberFormat\` to enable country / currency sensitive formatting.
|
||||
|
||||
`,
|
||||
'comments': [`// €123,456.79 | currency: Euro | currencyLangFormat: Local`,`// €123,456.79 | currency: US Dollar | currencyLangFormat: English (United States)`,`// ۱۲۳٬۴۵۶٫۷۹ $ | currency: US Dollar | currencyLangFormat: Farsi`,`// ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local`,`// 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish`],
|
||||
'hash': 'd1c86c6f075b79b53b74aede9669101f1a07e89cc73ccabf347ad42674b1a33c'
|
||||
'comments': [`// €123,456.79 | currency: Euro | currencyLangFormat: Local`,`// $123,456.79 | currency: US Dollar | currencyLangFormat: English (United States)`,`// ۱۲۳٬۴۵۶٫۷۹ $ | currency: US Dollar | currencyLangFormat: Farsi`,`// ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local`,`// 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish`],
|
||||
'hash': 'f00f4a2229ed6b9f98356e6b0ea9e245f1d53bdbd616eb4c2babb87d7cf350b9'
|
||||
},
|
||||
'toDecimalMark' : {
|
||||
'description': `### toDecimalMark
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
Thu Feb 08 2018 14:34:19 GMT+0200 (GTB Standard Time)
|
||||
Hash changes: 0
|
||||
Thu Feb 08 2018 16:08:53 GMT+0200 (GTB Standard Time)
|
||||
Hash changes: 1
|
||||
|
||||
Snippet name:toCurrency
|
||||
Old hash: d1c86c6f075b79b53b74aede9669101f1a07e89cc73ccabf347ad42674b1a33c
|
||||
New hash: f00f4a2229ed6b9f98356e6b0ea9e245f1d53bdbd616eb4c2babb87d7cf350b9
|
||||
|
||||
@ -11,7 +11,7 @@ const toCurrency = (n, curr, LanguageFormat = undefined) =>
|
||||
|
||||
```js
|
||||
toCurrency(123456.789, 'EUR'); // €123,456.79 | currency: Euro | currencyLangFormat: Local
|
||||
toCurrency(123456.789, 'USD', 'en-us'); // €123,456.79 | currency: US Dollar | currencyLangFormat: English (United States)
|
||||
toCurrency(123456.789, 'USD', 'en-us'); // $123,456.79 | currency: US Dollar | currencyLangFormat: English (United States)
|
||||
toCurrency(123456.789, 'USD', 'fa'); // ۱۲۳٬۴۵۶٫۷۹ $ | currency: US Dollar | currencyLangFormat: Farsi
|
||||
toCurrency(322342436423.2435, 'JPY'); // ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local
|
||||
toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish
|
||||
|
||||
@ -12,7 +12,7 @@ test('Testing functionName', (t) => {
|
||||
t.true(typeof functionName === 'function', 'functionName is a Function');
|
||||
functionName(Math.max);
|
||||
t.equal(output, 'max', 'Works for native functions');
|
||||
function fun(x) {return x};
|
||||
function fun(x) {return x;}
|
||||
functionName(fun);
|
||||
t.equal(output, 'fun', 'Works for functions');
|
||||
const fn = x => x;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
Test log for: Thu Feb 08 2018 15:59:54 GMT+0200 (GTB Standard Time)
|
||||
Test log for: Thu Feb 08 2018 16:08:45 GMT+0200 (GTB Standard Time)
|
||||
|
||||
> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
|
||||
> tape test/**/*.test.js | tap-spec
|
||||
@ -1490,6 +1490,9 @@ Test log for: Thu Feb 08 2018 15:59:54 GMT+0200 (GTB Standard Time)
|
||||
Testing toCurrency
|
||||
|
||||
√ toCurrency is a Function
|
||||
√ currency: Euro | currencyLangFormat: Local
|
||||
√ currency: US Dollar | currencyLangFormat: English (United States)
|
||||
√ currency: Japanese Yen | currencyLangFormat: Local
|
||||
|
||||
Testing toDecimalMark
|
||||
|
||||
@ -1754,8 +1757,8 @@ Test log for: Thu Feb 08 2018 15:59:54 GMT+0200 (GTB Standard Time)
|
||||
√ Works with multiple promises
|
||||
|
||||
|
||||
total: 852
|
||||
passing: 852
|
||||
total: 855
|
||||
passing: 855
|
||||
duration: 2.4s
|
||||
|
||||
|
||||
|
||||
@ -5,9 +5,14 @@ test('Testing toCurrency', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof toCurrency === 'function', 'toCurrency is a Function');
|
||||
t.equal(toCurrency(123456.789, 'EUR'), '€ 123,456.79', 'currency: Euro | currencyLangFormat: Local');
|
||||
t.equal(toCurrency(123456.789, 'USD', 'en-us'), '$123,456.79', ' currency: US Dollar | currencyLangFormat: English (United States)');
|
||||
//t.equal(toCurrency(123456.789, 'USD', 'fa'), '۱۲۳٬۴۵۶٫۷۹ $', 'currency: US Dollar | currencyLangFormat: Farsi'); - These break in node
|
||||
t.equal(toCurrency(322342436423.2435, 'JPY'), 'JP¥ 322,342,436,423', 'currency: Japanese Yen | currencyLangFormat: Local');
|
||||
//t.equal(toCurrency(322342436423.2435, 'JPY', 'fi'), '322 342 436 423 ¥', 'currency: Japanese Yen | currencyLangFormat: Finnish'); - These break in node
|
||||
//t.deepEqual(toCurrency(args..), 'Expected');
|
||||
//t.equal(toCurrency(args..), 'Expected');
|
||||
//t.false(toCurrency(args..), 'Expected');
|
||||
//t.throws(toCurrency(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user