From 491f2d03cfd790e4246a9fa638a2eecb07a6488a Mon Sep 17 00:00:00 2001 From: trejgun Date: Mon, 2 Jul 2018 09:36:57 +0800 Subject: move removeLeadingZeroes to utils, add test --- ui/app/components/send_/send.utils.test.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ui/app/components/send_/send.utils.test.js (limited to 'ui/app/components/send_/send.utils.test.js') diff --git a/ui/app/components/send_/send.utils.test.js b/ui/app/components/send_/send.utils.test.js new file mode 100644 index 000000000..36f3a5c10 --- /dev/null +++ b/ui/app/components/send_/send.utils.test.js @@ -0,0 +1,30 @@ +import assert from 'assert' +import { removeLeadingZeroes } from './send.utils' + + +describe('send utils', () => { + describe('removeLeadingZeroes()', () => { + it('should remove leading zeroes from int when user types', () => { + assert.equal(removeLeadingZeroes('0'), '0') + assert.equal(removeLeadingZeroes('1'), '1') + assert.equal(removeLeadingZeroes('00'), '0') + assert.equal(removeLeadingZeroes('01'), '1') + }) + + it('should remove leading zeroes from int when user copy/paste', () => { + assert.equal(removeLeadingZeroes('001'), '1') + }) + + it('should remove leading zeroes from float when user types', () => { + assert.equal(removeLeadingZeroes('0.'), '0.') + assert.equal(removeLeadingZeroes('0.0'), '0.0') + assert.equal(removeLeadingZeroes('0.00'), '0.00') + assert.equal(removeLeadingZeroes('0.001'), '0.001') + assert.equal(removeLeadingZeroes('0.10'), '0.10') + }) + + it('should remove leading zeroes from float when user copy/paste', () => { + assert.equal(removeLeadingZeroes('00.1'), '0.1') + }) + }) +}) -- cgit