aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/send_/send.utils.test.js
blob: 36f3a5c101a3ccc559b3f9a62567ee7727ef74af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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')
    })
  })
})