Page MenuHomePhabricator

[Cashtab] formatDate function patch
ClosedPublic

Authored by kieran709 on Jan 7 2022, 20:59.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABC8608f16e05ee: [Cashtab] formatDate function patch
Summary

Refactored format date to accept an optional useLocale paramater, included this parameter where the function is used throughout the app, and updated the unit tests to include a locale to ensure consistent results. Related to task T2139

Test Plan

cd web/cashtab && npm start
Check that dates on wallet tab match browser's locale
Check that dates on SendToken page match browser's locale
In browser settings, switch to another language.
Check that dates on wallet tab match browser's locale
Check that dates on SendToken pafe match browser's locale.

npm test
ensure that all tests pass.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bytesofman requested changes to this revision.Jan 9 2022, 21:15
bytesofman added inline comments.
web/cashtab/src/utils/__tests__/formatting.test.js
62 ↗(On Diff #31704)

Should this be expected to be en format or is that because your machine is in en format?

web/cashtab/src/utils/formatting.js
3 ↗(On Diff #31704)

(dateString, userLocale) change to dateString, userLocale=en; that way if userLocale is not specified the function will fall back to a known default

This revision now requires changes to proceed.Jan 9 2022, 21:15

Responding to review feedback, hardcoded the userLocale param to equal en and removed the optional locale param from the new Date function in the unit tests.

bytesofman added inline comments.
web/cashtab/src/utils/__tests__/formatting.test.js
52 ↗(On Diff #31729)

Would the output of this expression be different for a user in France vs Canada?

Make sure that locale is specified everywhere in the unit tests, that way what we are testing does not vary with region (and, in cases where the test might still have technically passed, the snapshots won't change).

This revision now requires changes to proceed.Jan 10 2022, 22:36

hard coded en-US into all unit tests per review feedback.

This revision is now accepted and ready to land.Jan 11 2022, 19:36
This revision was automatically updated to reflect the committed changes.