nl-nl.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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: nl-nl', function() {
  8. before(function() {
  9. numeral.locale('nl-nl');
  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,2mln'],
  26. [1430974124,'0.0a','1,4mrd'],
  27. [9123456789234,'0.0a','9,1bln'],
  28. [1460,'0a','1k'],
  29. [-104000,'0a','-104k'],
  30. [0,'0o','0de'],
  31. [1,'0o','1ste'],
  32. [2,'0o','2de'],
  33. [8,'0o','8ste'],
  34. [19,'0o','19de'],
  35. [20,'0o','20ste'],
  36. [100,'0o','100ste'],
  37. [102,'0o','102de'],
  38. [108,'0o','108ste'],
  39. [109,'0o','109de'],
  40. [1,'0[.]0','1']
  41. ];
  42. for (var i = 0; i < tests.length; i++) {
  43. expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]);
  44. }
  45. });
  46. });
  47. describe('Currency', function() {
  48. it('should format a currency', function() {
  49. var tests = [
  50. [1000.234,'$0,0.00','€ 1.000,23'],
  51. [-1000.234,'($0,0)','(€ 1.000)'],
  52. [-1000.234,'$0.00','-€ 1000,23'],
  53. [1230974,'($0.00a)','€ 1,23mln']
  54. ];
  55. for (var i = 0; i < tests.length; i++) {
  56. expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]);
  57. }
  58. });
  59. });
  60. describe('Percentages', function() {
  61. it('should format a percentages', function() {
  62. var tests = [
  63. [1,'0%','100%'],
  64. [0.974878234,'0.000%','97,488%'],
  65. [-0.43,'0%','-43%'],
  66. [0.43,'(0.000%)','43,000%']
  67. ];
  68. for (var i = 0; i < tests.length; i++) {
  69. expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]);
  70. }
  71. });
  72. });
  73. describe('Unformat', function() {
  74. it('should unformat', function() {
  75. var tests = [
  76. ['10.000,123',10000.123],
  77. ['(0,12345)',-0.12345],
  78. ['(€ 1,23 mln)',-1230000],
  79. ['10k',10000],
  80. ['-10k',-10000],
  81. ['23e',23],
  82. ['€ 10.000,00',10000],
  83. ['-76%',-0.76],
  84. ['2:23:57',8637]
  85. ];
  86. for (var i = 0; i < tests.length; i++) {
  87. expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]);
  88. }
  89. });
  90. });
  91. });