commas_spec.coffee 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. describe '#commas', ->
  2. it 'should insert commas into long numbers', ->
  3. # zero
  4. Morris.commas(0).should.equal("0")
  5. # positive integers
  6. Morris.commas(1).should.equal("1")
  7. Morris.commas(12).should.equal("12")
  8. Morris.commas(123).should.equal("123")
  9. Morris.commas(1234).should.equal("1,234")
  10. Morris.commas(12345).should.equal("12,345")
  11. Morris.commas(123456).should.equal("123,456")
  12. Morris.commas(1234567).should.equal("1,234,567")
  13. # negative integers
  14. Morris.commas(-1).should.equal("-1")
  15. Morris.commas(-12).should.equal("-12")
  16. Morris.commas(-123).should.equal("-123")
  17. Morris.commas(-1234).should.equal("-1,234")
  18. Morris.commas(-12345).should.equal("-12,345")
  19. Morris.commas(-123456).should.equal("-123,456")
  20. Morris.commas(-1234567).should.equal("-1,234,567")
  21. # positive decimals
  22. Morris.commas(1.2).should.equal("1.2")
  23. Morris.commas(12.34).should.equal("12.34")
  24. Morris.commas(123.456).should.equal("123.456")
  25. Morris.commas(1234.56).should.equal("1,234.56")
  26. # negative decimals
  27. Morris.commas(-1.2).should.equal("-1.2")
  28. Morris.commas(-12.34).should.equal("-12.34")
  29. Morris.commas(-123.456).should.equal("-123.456")
  30. Morris.commas(-1234.56).should.equal("-1,234.56")
  31. # null
  32. Morris.commas(null).should.equal('-')