-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathstring.test.js
83 lines (74 loc) · 3.22 KB
/
string.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
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
/*
* 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'); // eslint-disable-line no-unused-vars
describe('String', () => {
it('#format', () => {
should(String.format).not.be.undefined();
should(String.format).be.a.Function();
should(String.format('formatString', 'value')).be.a.String();
});
it('#formatCurrency', () => {
should(String.formatCurrency).not.be.undefined();
should(String.formatCurrency).be.a.Function();
should(String.formatCurrency(123)).be.a.String();
});
it('#formatDate', () => {
should(String.formatDate).not.be.undefined();
should(String.formatDate).be.a.Function();
should(String.formatDate(new Date())).be.a.String();
});
it('#formatDecimal', () => {
should(String.formatDecimal).not.be.undefined();
should(String.formatDecimal).be.a.Function();
should(String.formatDecimal(123)).be.a.String();
});
it('#formatTime', () => {
should(String.formatTime).not.be.undefined();
should(String.formatTime).be.a.Function();
should(String.formatTime(new Date())).be.a.String();
});
it('#localeCompare()', () => {
const string1 = 'réservé';
const string2 = 'RESERVE';
should(string1.localeCompare).not.be.undefined();
should(string1.localeCompare).be.a.Function();
should(string1.localeCompare(string2)).be.a.Number();
should(string1.localeCompare(string2)).be.above(0);
should(string1.localeCompare(string2, 'en')).be.above(0);
should(string1.localeCompare(string2, [ 'en' ])).be.above(0);
should(string1.localeCompare(string2, [ 'en', 'de' ])).be.above(0);
should(string1.localeCompare(string2, undefined, { sensitivity: 'base' })).be.eql(0);
should(string1.localeCompare(string2, 'en', { sensitivity: 'base' })).be.eql(0);
should(string1.localeCompare(string2, [ 'en' ], { sensitivity: 'base' })).be.eql(0);
should(string1.localeCompare(string2, [ 'en', 'de' ], { sensitivity: 'base' })).be.eql(0);
});
it('#toLocaleLowerCase()', () => {
const text = 'İstanbul';
should(text.toLocaleLowerCase).not.be.undefined();
should(text.toLocaleLowerCase).be.a.Function();
should(text.toLocaleLowerCase()).be.a.String();
should(text.toLocaleLowerCase('en-US')).be.eql('i̇stanbul');
should(text.toLocaleLowerCase([ 'en-US' ])).be.eql('i̇stanbul');
should(text.toLocaleLowerCase([ 'en-US', 'de-DE' ])).be.eql('i̇stanbul');
should(text.toLocaleLowerCase('tr-TR')).be.eql('istanbul');
should(text.toLocaleLowerCase([ 'tr-TR' ])).be.eql('istanbul');
});
it('#toLocaleUpperCase()', () => {
const text = 'istanbul';
should(text.toLocaleUpperCase).not.be.undefined();
should(text.toLocaleUpperCase).be.a.Function();
should(text.toLocaleUpperCase()).be.a.String();
should(text.toLocaleUpperCase('en-US')).be.eql('ISTANBUL');
should(text.toLocaleUpperCase([ 'en-US' ])).be.eql('ISTANBUL');
should(text.toLocaleUpperCase([ 'en-US', 'de-DE' ])).be.eql('ISTANBUL');
should(text.toLocaleUpperCase('tr-TR')).be.eql('İSTANBUL');
should(text.toLocaleUpperCase([ 'tr-TR' ])).be.eql('İSTANBUL');
});
});