Skip to content

Commit 32c57e7

Browse files
authored
test: price formatter with the original test cases (#2786)
1 parent 186adf6 commit 32c57e7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

__tests__/common/paddle/pricing.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,34 @@ describe('getPrice', () => {
107107
});
108108
});
109109

110+
it('should handle Indian Rupee format', () => {
111+
const result = getPrice({ formatted: '₹49.97', locale: 'en-IN' });
112+
expect(result).toEqual({
113+
amount: 49.97,
114+
formatted: '₹49.97',
115+
});
116+
});
117+
118+
it('should handle Swedish Krona format with symbol after amount', () => {
119+
const result = getPrice({
120+
formatted: '1499,00 kr',
121+
locale: 'sv-SE',
122+
divideBy: 30, // Convert monthly to daily price
123+
});
124+
expect(result).toEqual({
125+
amount: 49.97,
126+
formatted: '49,97 kr',
127+
});
128+
});
129+
130+
it('should handle Brazilian Real format with specific spacing', () => {
131+
const result = getPrice({ formatted: 'R$ 149,90', locale: 'pt-BR' });
132+
expect(result).toEqual({
133+
amount: 149.9,
134+
formatted: 'R$ 149,90',
135+
});
136+
});
137+
110138
// we have not covered the case where there are multiple spaces within the format and negative values
111139
});
112140

0 commit comments

Comments
 (0)