index.js 785 B

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * Module dependencies.
  3. */
  4. var humanize = require('..');
  5. describe('humanize(n, options)', function(){
  6. it('should delimit thousandths', function(){
  7. humanize(1000).should.equal('1,000');
  8. humanize(1000000).should.equal('1,000,000');
  9. humanize(10500).should.equal('10,500');
  10. })
  11. it('should retain fractions', function(){
  12. humanize(15.99).should.equal('15.99');
  13. humanize(1500.99).should.equal('1,500.99');
  14. })
  15. describe('"delimiter" option', function(){
  16. it('should change the delimiter', function(){
  17. humanize(1500, { delimiter: '.' }).should.equal('1.500');
  18. })
  19. })
  20. describe('"separator" option', function(){
  21. it('should change the separator', function(){
  22. humanize(15.99, { separator: ',' }).should.equal('15,99');
  23. })
  24. })
  25. })