bps.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Node
  2. if (typeof module !== 'undefined' && module.exports) {
  3. var numeral = require('../../numeral');
  4. var expect = require('chai').expect;
  5. }
  6. describe('BPS', function() {
  7. after(function() {
  8. numeral.reset();
  9. });
  10. it('should format to bps', function() {
  11. var tests = [
  12. [0,'0 BPS','0 BPS'],
  13. [0.0001, '0 BPS', '1 BPS'],
  14. [.0056, '0 BPS', '56 BPS'],
  15. [.25, '0BPS', '2500BPS'],
  16. [.000001, '0.00 BPS', '0.01 BPS']
  17. ],
  18. i;
  19. for (i = 0; i < tests.length; i++) {
  20. expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]);
  21. }
  22. });
  23. it('should unformat to number', function() {
  24. var tests = [
  25. ['0 BPS', 0],
  26. ['1 BPS', 0.0001],
  27. ['56 BPS', .0056],
  28. ['2500BPS', .25],
  29. ['0.01 BPS', .000001]
  30. ],
  31. i;
  32. for (i = 0; i < tests.length; i++) {
  33. expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]);
  34. }
  35. });
  36. });