New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: refactoring currency module to use central geo data [ATLAS-167] #119
Conversation
🦋 Changeset detectedLatest commit: 6f68562 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This comment has been minimized.
This comment has been minimized.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #119 +/- ##
===========================================
- Coverage 95.00% 84.57% -10.44%
===========================================
Files 44 49 +5
Lines 501 590 +89
Branches 128 147 +19
===========================================
+ Hits 476 499 +23
- Misses 24 84 +60
- Partials 1 7 +6 ☔ View full report in Codecov by Sentry. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…' into feat/currency-geo-data-migration
This comment has been minimized.
This comment has been minimized.
Bundle Size Report
|
🟢 No Change | 🗑 File Deleted | 🆕 New File | 📈 Size Increased | 👍 Size Reduced |
---|
Parsed (kb) | |||||
---|---|---|---|---|---|
🚦 | File Name | Base | PR | Diff | % |
👍 | cjs/index.js |
143.6 |
138.9 |
|
-3.27 |
👍 | esm/index.min.js |
53.71 |
51.45 |
|
-4.21 |
👍 | umd/index.js |
163.03 |
158.85 |
|
-2.56 |
… into feat/i18nify-data-alias
…at/currency-geo-data-migration
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
packages/i18nify-js/src/modules/currency/__tests__/convertToMinorUnit.test.ts
Outdated
Show resolved
Hide resolved
packages/i18nify-js/src/modules/currency/__tests__/formatNumber.test.ts
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -21,7 +22,7 @@ describe('getIntlInstanceWithOptions', () => { | |||
}); | |||
|
|||
it('should handle currency options', () => { | |||
const currency = 'EUR'; | |||
const currency = 'EUR' as CurrencyCodeType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant type cast.
export type CurrencyCodeType = keyof typeof CURRENCIES; | ||
export type CurrencyCodeType = keyof typeof CURRENCY_INFO; | ||
|
||
export interface CurrencySubsetData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not call this type CurrencySubsetData.
Just Currency should be fine IMO.
expect(sampleCurrency.symbol).toBe(CURRENCIES[sampleCurrencyCode].symbol); | ||
expect(sampleCurrency.name).toBe(CURRENCIES[sampleCurrencyCode].name); | ||
expect(sampleCurrency.symbol).toBe( | ||
(CURRENCY_INFO as CurrencySubsetData)[sampleCurrencyCode].symbol, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this typecast required here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
This comment has been minimized.
This comment has been minimized.
@@ -17,10 +19,12 @@ describe('getCurrencyList', () => { | |||
it("check the values of 'symbol' and 'name' properties for a sample currency", () => { | |||
const currencyList = getCurrencyList(); | |||
const sampleCurrencyCode = 'USD'; | |||
const sampleCurrency = currencyList[sampleCurrencyCode]; | |||
const sampleCurrency: Currency[string] = currencyList[sampleCurrencyCode]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this translate to string
?
Also, is it needed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's needed, since currency interface looks like below:
export interface Currency {
[key: string]: {
name: string;
minor_unit: string;
symbol: string;
};
}
and sampleCurrency is supposed to store value like below:
{
name: "Indian Rupee",
minor_unit: "2",
symbol: "₹"
}
|
||
const minorUnitMultiplier = currencyInfo.minorUnitMultiplier || 100; | ||
const majorUnitMultiplier = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either name this minorUnitMultiplier or majorUnitDivider
Unit Test Results0 files 0 suites 0s ⏱️ Results for commit 6f68562. |
Description
This PR updates currency module apis to now use central geo data (i18nify-data) rather that using modular static data.
Changes Made
List the main changes made in this pull request.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Additional Notes
Any additional information that would be helpful for the reviewer.
Checklist:
Reviewer Checklist
PR Title Format
Format:
<type>: <subject>
Types can be as follows:
feat
: (new feature for the user, not a new feature for build script)fix
: (bug fix for the user, not a fix to a build script)docs
: (changes to the documentation)style
: (formatting, missing semi colons, etc; no production code change)refactor
: (refactoring production code, eg. renaming a variable)test
: (adding missing tests, refactoring tests; no production code change)chore
: (updating grunt tasks etc; no production code change)