Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit fad75ff

Browse files
authored
Merge branch 'master' into symbol-service
2 parents a6733a6 + 6be9b75 commit fad75ff

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/*
22
npm-debug.log
33
coverage/
44
build/
5+
package-lock.json

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"colors": "^1.1.2 ",
1313
"commander": "^2.9.0",
1414
"convert-units": "^2.0.1",
15-
"currency-symbol-map": "^3.1.0",
1615
"enumify": "^1.0.4",
1716
"immutable": "^3.8.1",
1817
"node-emoji": "^1.4.3",

src/services/tables/TripPriceEstimateRowFormatter.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import CurrencySymbol from 'currency-symbol-map';
2+
23
import { List, Map } from 'immutable';
34

45
import DistanceUnit from '../../data/DistanceUnit';
@@ -26,8 +27,15 @@ export default class TripPriceEstimateRowFormatter {
2627
}
2728

2829
formatRange(range) {
29-
const currencySymbol = CurrencySymbol(range.currencyCode);
30-
return `${currencySymbol}${range.low}-${currencySymbol}${range.high}`;
30+
return `${this.formatCurrencyValue(range.low, range.currencyCode)}-${this.formatCurrencyValue(range.high, range.currencyCode)}`;
31+
}
32+
33+
formatCurrencyValue(value, currencyCode) {
34+
return Intl.NumberFormat('en-US', {
35+
style: 'currency',
36+
maximumFractionDigits: 0,
37+
currency: currencyCode,
38+
}).format(value);
3139
}
3240

3341
formatDistance(distance, rowDistanceUnit) {

test/services/tables/TripPriceEstimateRowFormatterTest.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,26 @@ describe('Trip Price Estimate Row Formatter', () => {
4949
it('throws exception', () => expect(() => rowFormatter.getDistanceUnitAbbreviation('foo')).to.throw(TypeError));
5050
});
5151

52-
describe('format range', () => {
52+
describe('#formatRange', () => {
5353
const range = {
5454
currencyCode: 'USD',
5555
low: 'foo',
5656
high: 'bar',
5757
};
5858

5959
it('successfully', () => {
60-
const expected = '$foo-$bar';
60+
sandbox.stub(rowFormatter, 'formatCurrencyValue').callsFake((value, currencyCode) => `${value}-${currencyCode}`);
61+
const expected = 'foo-USD-bar-USD';
6162
expect(rowFormatter.formatRange(range)).to.eql(expected);
6263
});
6364
});
6465

66+
describe('#formatCurrencyValue', () => {
67+
it('succeeds', () => {
68+
expect(rowFormatter.formatCurrencyValue(1234.567, 'USD')).to.eql('$1,235');
69+
});
70+
});
71+
6572
describe('format distance', () => {
6673
it('succeeds', () => {
6774
const distanceConversion = sinon.stub(distanceConverter, 'convert').returns({ value: 1 });

0 commit comments

Comments
 (0)