Add tests for toCurrency

This commit is contained in:
Angelos Chalaris
2018-02-08 16:09:39 +02:00
parent bd0f6c1625
commit 1b2ab92afb
8 changed files with 28 additions and 14 deletions

View File

@ -2871,8 +2871,8 @@ Take a number and return specified currency formatting.
Use \`Intl.NumberFormat\` to enable country / currency sensitive 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`], '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' 'hash': 'f00f4a2229ed6b9f98356e6b0ea9e245f1d53bdbd616eb4c2babb87d7cf350b9'
}, },
'toDecimalMark' : { 'toDecimalMark' : {
'description': `### toDecimalMark 'description': `### toDecimalMark

View File

@ -1,3 +1,6 @@
Thu Feb 08 2018 14:34:19 GMT+0200 (GTB Standard Time) Thu Feb 08 2018 16:08:52 GMT+0200 (GTB Standard Time)
Hash changes: 0 Hash changes: 1
Snippet name:toCurrency
Old hash: d1c86c6f075b79b53b74aede9669101f1a07e89cc73ccabf347ad42674b1a33c
New hash: f00f4a2229ed6b9f98356e6b0ea9e245f1d53bdbd616eb4c2babb87d7cf350b9

View File

@ -2871,8 +2871,8 @@ Take a number and return specified currency formatting.
Χρησιμοποιείται \`Intl.NumberFormat\` to enable country / currency sensitive 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`], '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' 'hash': 'f00f4a2229ed6b9f98356e6b0ea9e245f1d53bdbd616eb4c2babb87d7cf350b9'
}, },
'toDecimalMark' : { 'toDecimalMark' : {
'description': `### toDecimalMark 'description': `### toDecimalMark

View File

@ -1,3 +1,6 @@
Thu Feb 08 2018 14:34:19 GMT+0200 (GTB Standard Time) Thu Feb 08 2018 16:08:53 GMT+0200 (GTB Standard Time)
Hash changes: 0 Hash changes: 1
Snippet name:toCurrency
Old hash: d1c86c6f075b79b53b74aede9669101f1a07e89cc73ccabf347ad42674b1a33c
New hash: f00f4a2229ed6b9f98356e6b0ea9e245f1d53bdbd616eb4c2babb87d7cf350b9

View File

@ -11,7 +11,7 @@ const toCurrency = (n, curr, LanguageFormat = undefined) =>
```js ```js
toCurrency(123456.789, 'EUR'); // €123,456.79 | currency: Euro | currencyLangFormat: Local 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(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'); // ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local
toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish

View File

@ -12,7 +12,7 @@ test('Testing functionName', (t) => {
t.true(typeof functionName === 'function', 'functionName is a Function'); t.true(typeof functionName === 'function', 'functionName is a Function');
functionName(Math.max); functionName(Math.max);
t.equal(output, 'max', 'Works for native functions'); t.equal(output, 'max', 'Works for native functions');
function fun(x) {return x}; function fun(x) {return x;}
functionName(fun); functionName(fun);
t.equal(output, 'fun', 'Works for functions'); t.equal(output, 'fun', 'Works for functions');
const fn = x => x; const fn = x => x;

View File

@ -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 > 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
> tape test/**/*.test.js | tap-spec > 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 Testing toCurrency
√ toCurrency is a Function √ toCurrency is a Function
√ currency: Euro | currencyLangFormat: Local
√ currency: US Dollar | currencyLangFormat: English (United States)
√ currency: Japanese Yen | currencyLangFormat: Local
Testing toDecimalMark 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 √ Works with multiple promises
total: 852 total: 855
passing: 852 passing: 855
duration: 2.4s duration: 2.4s

View File

@ -5,9 +5,14 @@ test('Testing toCurrency', (t) => {
//For more information on all the methods supported by tape //For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape //Please go to https://github.com/substack/tape
t.true(typeof toCurrency === 'function', 'toCurrency is a Function'); 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.deepEqual(toCurrency(args..), 'Expected');
//t.equal(toCurrency(args..), 'Expected'); //t.equal(toCurrency(args..), 'Expected');
//t.false(toCurrency(args..), 'Expected'); //t.false(toCurrency(args..), 'Expected');
//t.throws(toCurrency(args..), 'Expected'); //t.throws(toCurrency(args..), 'Expected');
t.end(); t.end();
}); });