Skip to content

Commit

Permalink
#39 - fixing problem with precision zero thousand dot
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpmartins committed Aug 22, 2021
1 parent 7cea955 commit 07725be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function format(input, opt = defaults, caller) {
const negative = opt.disableNegative ? '' : (input.indexOf('-') >= 0 ? '-' : '');
let filtered = input.replace(opt.prefix, '').replace(opt.suffix, '');
if (opt.debug) console.log('utils format() - filtered', filtered);
if (!opt.precision && BigNumber.isValidFloat(filtered)) {
if (!opt.precision && opt.thousands !== '.' && BigNumber.isValidFloat(filtered)) {
filtered = BigNumber.round(filtered, 0);
if (opt.debug) console.log('utils format() - !opt.precision && isValidFloat()', filtered);
}
Expand Down
11 changes: 11 additions & 0 deletions tests/puppeteer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,15 @@ describe('Puppeteer Tests', () => {

expect(await getValue()).toBe('1,234,567.89');
});

it('Test if precision "0" (zero) with thousand "." (dot) work correctly', async () => {
await page.goto(`${serverUrl}?precision=0&thousands=.&debug=true`);

await page.focus('#component');
await page.type('#component', '123456789');

// await page.type('#component', '6');

expect(await getValue()).toBe('123.456.789');
});
});

0 comments on commit 07725be

Please sign in to comment.