|
|
@@ -0,0 +1,44 @@
|
|
|
+import { expect } from 'chai';
|
|
|
+import { isNumber, roundForObj, roundToString } from '../src/index';
|
|
|
+
|
|
|
+describe('Test', () => {
|
|
|
+ it('test number', () => {
|
|
|
+ const testStr = isNumber(5);
|
|
|
+ expect(testStr).to.equal(true);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('test string', () => {
|
|
|
+ const testStr = isNumber('6666666');
|
|
|
+ expect(testStr).to.equal(true);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('test string2', () => {
|
|
|
+ const testStr = isNumber('ddd');
|
|
|
+ expect(testStr).to.equal(false);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('to number', () => {
|
|
|
+ const num = roundForObj('152222.33334', 3);
|
|
|
+ expect(num).to.equal(152222.333);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('to number2', () => {
|
|
|
+ const num = roundForObj(152222.33334, 3);
|
|
|
+ expect(num).to.equal(152222.333);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('to number3', () => {
|
|
|
+ const num = roundForObj('ffff', 3);
|
|
|
+ expect(num).to.equal(0);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('to string', () => {
|
|
|
+ const str = roundToString('152222.3339', 3);
|
|
|
+ expect(str).to.equal('152222.334');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('to string2', () => {
|
|
|
+ const str = roundToString(152222.3339, 3);
|
|
|
+ expect(str).to.equal('152222.334');
|
|
|
+ });
|
|
|
+});
|