From 1b2ab92afb3cb6868c909c6cf5bc4c039d5d9b85 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Thu, 8 Feb 2018 16:09:39 +0200 Subject: [PATCH] Add tests for toCurrency --- locale/de_DE.js | 4 ++-- locale/de_DE_log | 7 +++++-- locale/el_GR.js | 4 ++-- locale/el_GR_log | 7 +++++-- snippets/toCurrency.md | 2 +- test/functionName/functionName.test.js | 2 +- test/testlog | 9 ++++++--- test/toCurrency/toCurrency.test.js | 7 ++++++- 8 files changed, 28 insertions(+), 14 deletions(-) diff --git a/locale/de_DE.js b/locale/de_DE.js index 4dd8391b0..d0fb35d73 100644 --- a/locale/de_DE.js +++ b/locale/de_DE.js @@ -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 diff --git a/locale/de_DE_log b/locale/de_DE_log index ae2ac493e..442f74b7e 100644 --- a/locale/de_DE_log +++ b/locale/de_DE_log @@ -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 diff --git a/locale/el_GR.js b/locale/el_GR.js index 95606a4aa..3ecfb6f21 100644 --- a/locale/el_GR.js +++ b/locale/el_GR.js @@ -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 diff --git a/locale/el_GR_log b/locale/el_GR_log index ae2ac493e..0d0fe70d0 100644 --- a/locale/el_GR_log +++ b/locale/el_GR_log @@ -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 diff --git a/snippets/toCurrency.md b/snippets/toCurrency.md index bfb5561da..90d77fa51 100644 --- a/snippets/toCurrency.md +++ b/snippets/toCurrency.md @@ -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 diff --git a/test/functionName/functionName.test.js b/test/functionName/functionName.test.js index e64a3d3be..4231f45c5 100644 --- a/test/functionName/functionName.test.js +++ b/test/functionName/functionName.test.js @@ -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; diff --git a/test/testlog b/test/testlog index c708ccd38..79372decd 100644 --- a/test/testlog +++ b/test/testlog @@ -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 diff --git a/test/toCurrency/toCurrency.test.js b/test/toCurrency/toCurrency.test.js index 5da0952c0..16423c0c1 100644 --- a/test/toCurrency/toCurrency.test.js +++ b/test/toCurrency/toCurrency.test.js @@ -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(); -}); \ No newline at end of file +});