Fix number conversion

This commit is contained in:
2020-06-11 22:33:44 +03:00
parent 1f58da5d58
commit 625e7f9836
2 changed files with 27 additions and 2 deletions

25
tests/UtilsTest.ts Normal file
View File

@ -0,0 +1,25 @@
import { it, describe } from 'mocha';
import { expect } from 'chai';
import { getNumber } from '../src/utils';
describe('Utils', function() {
it('Can parse positive number', function() {
const text = '123';
expect(getNumber(text)).to.be.equals(123);
});
it('Can parse positive number with noise', function() {
const text = ' 123 ';
expect(getNumber(text)).to.be.equals(123);
});
it('Can parse negative number', function() {
const text = '-146';
expect(getNumber(text)).to.be.equals(-146);
});
it('Can parse negative number with minus sign', function() {
const text = '\u2212132';
expect(getNumber(text)).to.be.equals(-132);
});
});