sk.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Node
  2. if (typeof module !== 'undefined' && module.exports) {
  3. var numeral = require('../../numeral');
  4. var locales = require('../../locales');
  5. var expect = require('chai').expect;
  6. }
  7. describe('Locale: sk', function() {
  8. before(function() {
  9. numeral.locale('sk');
  10. });
  11. after(function() {
  12. numeral.reset();
  13. });
  14. describe('Number', function() {
  15. it('should format a number', function() {
  16. var tests = [
  17. [10000,'0,0.0000','10 000,0000'],
  18. [10000.23,'0,0','10 000'],
  19. [-10000,'0,0.0','-10 000,0'],
  20. [10000.1234,'0.000','10000,123'],
  21. [-10000,'(0,0.0000)','(10 000,0000)'],
  22. [-0.23,'.00','-,23'],
  23. [-0.23,'(.00)','(,23)'],
  24. [0.23,'0.00000','0,23000'],
  25. [1230974,'0.0a','1,2mil.'],
  26. [1460,'0a','1tis.'],
  27. [-104000,'0a','-104tis.'],
  28. [1,'0o','1.'],
  29. [52,'0o','52.'],
  30. [23,'0o','23.'],
  31. [100,'0o','100.'],
  32. [1,'0[.]0','1']
  33. ];
  34. for (var i = 0; i < tests.length; i++) {
  35. expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]);
  36. }
  37. });
  38. });
  39. describe('Currency', function() {
  40. it('should format a currency', function() {
  41. var tests = [
  42. [1000.234,'$0,0.00','€1 000,23'],
  43. [-1000.234,'($0,0)','(€1 000)'],
  44. [-1000.234,'$0.00','-€1000,23'],
  45. [1230974,'($0.00a)','€1,23mil.']
  46. ];
  47. for (var i = 0; i < tests.length; i++) {
  48. expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]);
  49. }
  50. });
  51. });
  52. describe('Percentages', function() {
  53. it('should format a percentages', function() {
  54. var tests = [
  55. [1,'0%','100%'],
  56. [0.974878234,'0.000%','97,488%'],
  57. [-0.43,'0%','-43%'],
  58. [0.43,'(0.000%)','43,000%']
  59. ];
  60. for (var i = 0; i < tests.length; i++) {
  61. expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]);
  62. }
  63. });
  64. });
  65. describe('Unformat', function() {
  66. it('should unformat', function() {
  67. var tests = [
  68. ['10 000,123',10000.123],
  69. ['(0,12345)',-0.12345],
  70. ['(€1,23mil.)',-1230000],
  71. ['10tis.',10000],
  72. ['-10tis.',-10000],
  73. ['23e',23],
  74. ['€10 000,00',10000],
  75. ['-76%',-0.76],
  76. ['2:23:57',8637]
  77. ];
  78. for (var i = 0; i < tests.length; i++) {
  79. expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]);
  80. }
  81. });
  82. });
  83. });