forked from adamwdraper/Numeral-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
en-gb.js
94 lines (83 loc) · 2.84 KB
/
en-gb.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Node
if (typeof module !== 'undefined' && module.exports) {
var numeral = require('../../numeral');
var locales = require('../../locales');
var expect = require('chai').expect;
}
describe('Locale: en-gb', function() {
before(function() {
numeral.locale('en-gb');
});
after(function() {
numeral.reset();
});
describe('Number', function() {
it('should format a number', function() {
var tests = [
[10000,'0,0.0000','10,000.0000'],
[10000.23,'0,0','10,000'],
[-10000,'0,0.0','-10,000.0'],
[10000.1234,'0.000','10000.123'],
[-10000,'(0,0.0000)','(10,000.0000)'],
[-0.23,'.00','-.23'],
[-0.23,'(.00)','(.23)'],
[0.23,'0.00000','0.23000'],
[1230974,'0.0a','1.2m'],
[1460,'0a','1k'],
[-104000,'0a','-104k'],
[1,'0o','1st'],
[52,'0o','52nd'],
[23,'0o','23rd'],
[100,'0o','100th'],
[1,'0[.]0','1']
];
for (var i = 0; i < tests.length; i++) {
expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]);
}
});
});
describe('Currency', function() {
it('should format a currency', function() {
var tests = [
[1000.234,'$0,0.00','£1,000.23'],
[-1000.234,'($0,0)','(£1,000)'],
[-1000.234,'$0.00','-£1000.23'],
[1230974,'($0.00a)','£1.23m']
];
for (var i = 0; i < tests.length; i++) {
expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]);
}
});
});
describe('Percentages', function() {
it('should format a percentages', function() {
var tests = [
[1,'0%','100%'],
[0.974878234,'0.000%','97.488%'],
[-0.43,'0%','-43%'],
[0.43,'(0.000%)','43.000%']
];
for (var i = 0; i < tests.length; i++) {
expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]);
}
});
});
describe('Unformat', function() {
it('should unformat', function() {
var tests = [
['10,000.123',10000.123],
['(0.12345)',-0.12345],
['(£1.23m)',-1230000],
['10k',10000],
['-10k',-10000],
['23rd',23],
['£10,000.00',10000],
['-76%',-0.76],
['2:23:57',8637]
];
for (var i = 0; i < tests.length; i++) {
expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]);
}
});
});
});