/
number.test.js
34 lines (29 loc) 路 1.41 KB
/
number.test.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
/*
* Titanium SDK
* Copyright TiDev, Inc. 04/07/2022-Present. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';
const should = require('./utilities/assertions');
describe('Number', () => {
it('#toLocaleString()', () => {
const value = 1234567.8;
should(value.toLocaleString).not.be.undefined();
should(value.toLocaleString).be.a.Function();
should(value.toLocaleString()).be.a.String();
should(value.toLocaleString('en-US')).be.a.String();
should(value.toLocaleString([ 'en-US' ])).be.a.String();
should(value.toLocaleString([ 'en-US', 'de-DE' ])).be.a.String();
should(value.toLocaleString(undefined, { style: 'decimal' })).be.a.String();
should(value.toLocaleString('en-US', { style: 'decimal' })).be.a.String();
should(value.toLocaleString([ 'en-US' ], { style: 'decimal' })).be.a.String();
should(value.toLocaleString([ 'en-US', 'de-DE' ], { style: 'decimal' })).be.a.String();
should(value.toLocaleString('en-US', { useGrouping: false })).be.eql('1234567.8');
should(value.toLocaleString('en-US', { useGrouping: true })).be.eql('1,234,567.8');
should(value.toLocaleString('de-DE', { useGrouping: false })).be.eql('1234567,8');
should(value.toLocaleString('de-DE', { useGrouping: true })).be.eql('1.234.567,8');
});
});