Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
40d65e16
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
40d65e16
编写于
5月 17, 2023
作者:
Y
y00314596
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add by yangqing3@huawei.com
Signed-off-by:
N
y00314596
<
yangqing3@huawei.com
>
上级
7fb7368f
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
1561 addition
and
516 deletion
+1561
-516
global/i18n_standard/intljs/src/main/js/test/CollatorInIntl.test.js
...n_standard/intljs/src/main/js/test/CollatorInIntl.test.js
+224
-0
global/i18n_standard/intljs/src/main/js/test/DateTimeFormatInIntl.test.js
...dard/intljs/src/main/js/test/DateTimeFormatInIntl.test.js
+454
-0
global/i18n_standard/intljs/src/main/js/test/I18n.test.js
global/i18n_standard/intljs/src/main/js/test/I18n.test.js
+0
-459
global/i18n_standard/intljs/src/main/js/test/Lang.test.js
global/i18n_standard/intljs/src/main/js/test/Lang.test.js
+0
-55
global/i18n_standard/intljs/src/main/js/test/List.test.js
global/i18n_standard/intljs/src/main/js/test/List.test.js
+10
-2
global/i18n_standard/intljs/src/main/js/test/NumberFormatInIntl.test.js
...andard/intljs/src/main/js/test/NumberFormatInIntl.test.js
+475
-0
global/i18n_standard/intljs/src/main/js/test/PluralRulesInIntl.test.js
...tandard/intljs/src/main/js/test/PluralRulesInIntl.test.js
+193
-0
global/i18n_standard/intljs/src/main/js/test/RelativeTimeFormatInIntl.test.js
.../intljs/src/main/js/test/RelativeTimeFormatInIntl.test.js
+205
-0
未找到文件。
global/i18n_standard/intljs/src/main/js/test/CollatorInIntl.test.js
0 → 100644
浏览文件 @
40d65e16
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
I18n
from
'
@ohos.i18n
'
import
Intl
from
'
@ohos.intl
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
CollatorInIntlTest
()
{
describe
(
'
CollatorInIntlTest
'
,
function
()
{
console
.
log
(
'
*************start CollatorInIntlTest*************
'
);
let
hour
=
I18n
.
System
.
is24HourClock
();
console
.
log
(
'
init 24 hour clock value
'
+
hour
);
/* *
* execute this step before all testcases
*/
beforeAll
(
function
(){
console
.
log
(
'
step before all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* execute this step before every testcase
*/
beforeEach
(
function
(){
console
.
log
(
'
step before every case in I18n.
'
);
})
/* *
* execute this step after every testcase
*/
afterEach
(
function
(){
console
.
log
(
'
step after every case in I18n.
'
);
})
/* *
* execute this step after all testcases
*/
afterAll
(
function
(){
console
.
log
(
'
step after all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3500
* @tc.name compare two different strings
* @tc.desc check the compare result
*/
it
(
'
collator_test_3500
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
();
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3500
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3510
* @tc.name compare the same strings
* @tc.desc check the compare result
*/
it
(
'
collator_test_3510
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
();
let
value
=
coll
.
compare
(
'
a
'
,
'
a
'
);
console
.
log
(
'
collator_test_3100
'
+
value
);
expect
(
value
).
assertEqual
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3520
* @tc.name compare two different strings and return positive value
* @tc.desc check the compare result
*/
it
(
'
collator_test_3520
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
();
let
value
=
coll
.
compare
(
'
b
'
,
'
a
'
);
console
.
log
(
'
collator_test_3200
'
+
value
);
expect
(
value
).
assertEqual
(
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3600
* @tc.name compare two different strings with zh locale
* @tc.desc check the compare result
*/
it
(
'
collator_test_3600
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
);
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3600
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3620
* @tc.name compare two different strings with zh locale and undefined options
* @tc.desc check the compare result
*/
it
(
'
collator_test_3620
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
undefined
);
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3620
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3640
* @tc.name compare two different strings with zh locale and null options
* @tc.desc check the compare result
*/
it
(
'
collator_test_3640
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
null
);
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3640
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3700
* @tc.name compare two different strings with zh locale and eor collation
* @tc.desc check the compare result
*/
it
(
'
collator_test_3700
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
collation
'
:
'
eor
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3700
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
collation
).
assertEqual
(
'
eor
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3800
* @tc.name compare two different strings with zh locale and base sensitivity
* @tc.desc check the compare result
*/
it
(
'
collator_test_3800
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
sensitivity
'
:
'
base
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3800
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
sensitivity
).
assertEqual
(
'
base
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3900
* @tc.name compare two different strings with zh locale and upper caseFirst
* @tc.desc check the compare result
*/
it
(
'
collator_test_3900
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
caseFirst
'
:
'
upper
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3900
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
caseFirst
).
assertEqual
(
'
upper
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4000
* @tc.name compare two different strings with zh locale and true numeric
* @tc.desc check the compare result
*/
it
(
'
collator_test_4000
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
numeric
'
:
true
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4000
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
numeric
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4100
* @tc.name compare two different strings with zh locale and true ignorePunctuation
* @tc.desc check the compare result
*/
it
(
'
collator_test_4100
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
ignorePunctuation
'
:
true
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4100
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
ignorePunctuation
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4200
* @tc.name compare two different strings with zh locale and sort usage
* @tc.desc check the compare result
*/
it
(
'
collator_test_4200
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
usage
'
:
'
sort
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4200
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
usage
).
assertEqual
(
'
sort
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4300
* @tc.name compare the string with localeMatcher options
* @tc.desc check the compare result
*/
it
(
'
collator_test_4300
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
localeMatcher
'
:
'
lookup
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4300
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
localeMatcher
).
assertEqual
(
'
lookup
'
);
})
console
.
log
(
'
*************end CollatorInIntlTest*************
'
);
})}
global/i18n_standard/intljs/src/main/js/test/DateTimeFormatInIntl.test.js
0 → 100644
浏览文件 @
40d65e16
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
I18n
from
'
@ohos.i18n
'
import
Intl
from
'
@ohos.intl
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
DateTimeFormatInIntlTest
()
{
describe
(
'
DateTimeFormatInIntlTest
'
,
function
()
{
console
.
log
(
'
*************start DateTimeFormatInIntlTest*************
'
);
let
hour
=
I18n
.
System
.
is24HourClock
();
console
.
log
(
'
init 24 hour clock value
'
+
hour
);
/* *
* execute this step before all testcases
*/
beforeAll
(
function
(){
console
.
log
(
'
step before all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* execute this step before every testcase
*/
beforeEach
(
function
(){
console
.
log
(
'
step before every case in I18n.
'
);
})
/* *
* execute this step after every testcase
*/
afterEach
(
function
(){
console
.
log
(
'
step after every case in I18n.
'
);
})
/* *
* execute this step after all testcases
*/
afterAll
(
function
(){
console
.
log
(
'
step after all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0100
* @tc.name format the datetime with en-GB locale
* @tc.desc check the datetime is not null
*/
it
(
'
dateTimeFormat_test_0100
'
,
0
,
function
()
{
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
expect
(
datefmt
!==
null
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0120
* @tc.name format the datetime with en-GB locale
* @tc.desc check the datetime is not null
*/
it
(
'
dateTimeFormat_test_0120
'
,
0
,
function
()
{
let
datefmt
=
new
Intl
.
DateTimeFormat
();
expect
(
datefmt
!==
null
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0200
* @tc.name format the date with zh locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0200
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh
'
);
console
.
log
(
'
dateTimeFormat_test_0200
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2021
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0220
* @tc.name format the date with zh locale and undefined options
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0220
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh
'
,
undefined
);
console
.
log
(
'
dateTimeFormat_test_0220
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2021
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0240
* @tc.name format the date with zh locale and null options
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0240
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh
'
,
null
);
console
.
log
(
'
dateTimeFormat_test_0240
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2021
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0300
* @tc.name format the date with en locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0300
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en
'
);
console
.
log
(
'
dateTimeFormat_test_0300
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
21
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0310
* @tc.name format the date with en-US locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0310
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-US
'
);
console
.
log
(
'
dateTimeFormat_test_0310
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
21
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0320
* @tc.name format the date with en-GB locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0320
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
console
.
log
(
'
dateTimeFormat_test_0320
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2021
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0400
* @tc.name format the date with aa locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0400
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
aa
'
);
let
value
=
datefmt
.
format
(
date
);
console
.
log
(
'
dateTimeFormat_test_0400
'
+
value
);
expect
(
value
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0500
* @tc.name format the hour with ban and zh locale
* @tc.desc check the hour with ban and zh locale
*/
it
(
'
dateTimeFormat_test_0500
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
([
'
ban
'
,
'
zh
'
],
option
);
console
.
log
(
'
dateTimeFormat_test_0500
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
2020年12月20日星期日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0600
* @tc.name format the hour with en and zh locale
* @tc.desc check the hour with en and zh locale
*/
it
(
'
dateTimeFormat_test_0600
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
([
'
en
'
,
'
zh
'
],
option
);
console
.
log
(
'
dateTimeFormat_test_0600
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
Sunday, December 20, 2020
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0700
* @tc.name format the hour with en and ban locale
* @tc.desc check the hour with en and ban locale
*/
it
(
'
dateTimeFormat_test_0700
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
([
'
en
'
,
'
ban
'
],
option
);
console
.
log
(
'
dateTimeFormat_test_0700
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
Sunday, December 20, 2020
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0800
* @tc.name format the hour without correct locale
* @tc.desc check the hour without correct locale
*/
it
(
'
dateTimeFormat_test_0800
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
([
'
abc
'
,
'
ban
'
],
option
);
console
.
log
(
'
dateTimeFormat_test_0800
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2020
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0900
* @tc.name format the date with full datestyle and mediu timestyle
* @tc.desc check the date with full datestyle and mediu timestyle
*/
it
(
'
dateTimeFormat_test_0900
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
,
timeStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-Hans-CN
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_0900
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2020年12月20日星期日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1000
* @tc.name format the date dateStyle with long style
* @tc.desc check the dateStyle with long style
*/
it
(
'
dateTimeFormat_test_1000
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
long
'
,
timeStyle
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1000
'
+
datefmt
.
resolvedOptions
().
dateStyle
);
expect
(
datefmt
.
resolvedOptions
().
dateStyle
).
assertEqual
(
'
long
'
);
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2020年12月20日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1100
* @tc.name format the date dateStyle with medium style
* @tc.desc check the dateStyle with medium style
*/
it
(
'
dateTimeFormat_test_1100
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
medium
'
,
timeStyle
:
'
medium
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1100
'
+
datefmt
.
resolvedOptions
().
dateStyle
);
expect
(
datefmt
.
resolvedOptions
().
dateStyle
).
assertEqual
(
'
medium
'
);
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2020年12月20日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1200
* @tc.name format the date dateStyle with short style
* @tc.desc check the dateStyle with short style
*/
it
(
'
dateTimeFormat_test_1200
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
short
'
,
timeStyle
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1200
'
+
datefmt
.
resolvedOptions
().
dateStyle
);
expect
(
datefmt
.
resolvedOptions
().
dateStyle
).
assertEqual
(
'
short
'
);
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2020/12/20
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1300
* @tc.name format the date with daterange
* @tc.desc check the daterange
*/
it
(
'
dateTimeFormat_test_1300
'
,
0
,
function
()
{
let
startdate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
enddate
=
new
Date
(
2020
,
11
,
21
,
14
,
23
,
16
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
console
.
log
(
'
dateTimeFormat_test_1300
'
+
datefmt
.
formatRange
(
startdate
,
enddate
));
expect
(
datefmt
.
formatRange
(
startdate
,
enddate
)).
assertEqual
(
'
20/12/2020 – 21/12/2020
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1400
* @tc.name format the date with daterange when the start and end date is equal
* @tc.desc check the daterange when the start and end date is equal
*/
it
(
'
dateTimeFormat_test_1400
'
,
0
,
function
()
{
let
startdate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
enddate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
console
.
log
(
'
dateTimeFormat_test_1400
'
+
datefmt
.
formatRange
(
startdate
,
enddate
));
expect
(
datefmt
.
formatRange
(
startdate
,
enddate
)).
assertEqual
(
'
20/12/2020
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1500
* @tc.name format the year、month、day、weekday
* @tc.desc check the year、month、day、weekday
*/
it
(
'
dateTimeFormat_test_1500
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
weekday
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
ja
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1500
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
2020年12月20日日曜日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1600
* @tc.name format the timerange with year、month、day、weekday
* @tc.desc check the timerange with year、month、day、weekday
*/
it
(
'
dateTimeFormat_test_1600
'
,
0
,
function
()
{
let
startdate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
enddate
=
new
Date
(
2021
,
4
,
5
,
10
,
5
,
3
);
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
weekday
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1600
'
+
datefmt
.
formatRange
(
startdate
,
enddate
));
expect
(
datefmt
.
formatRange
(
startdate
,
enddate
)).
assertEqual
(
'
Sunday, December 20, 2020 – Wednesday, May 5, 2021
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1700
* @tc.name format the hour&minute&second
* @tc.desc check the hour&minute&second
*/
it
(
'
dateTimeFormat_test_1700
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1700
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
公元2020年12月20日星期日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1800
* @tc.name format the timeZone
* @tc.desc check the timeZone
*/
it
(
'
dateTimeFormat_test_1800
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
3
,
14
,
15
,
5
,
3
);
let
option
=
{
timeZone
:
'
America/Los_Angeles
'
,
timeZoneName
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1800
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
).
indexOf
(
'
北美太平洋夏令时间
'
)
!==
-
1
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1900
* @tc.name format the America/Los_Angeles timeZone
* @tc.desc check the America/Los_Angeles timeZone
*/
it
(
'
dateTimeFormat_test_1900
'
,
0
,
function
()
{
let
option
=
{
timeZone
:
'
America/Los_Angeles
'
,
timeZoneName
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1900
'
+
datefmt
.
resolvedOptions
().
timeZone
);
expect
(
datefmt
.
resolvedOptions
().
timeZone
).
assertEqual
(
'
America/Los_Angeles
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2000
* @tc.name format the America/Los_Angeles timeZoneName
* @tc.desc check the America/Los_Angeles timeZoneName
*/
it
(
'
dateTimeFormat_test_2000
'
,
0
,
function
()
{
let
option
=
{
timeZone
:
'
America/Los_Angeles
'
,
timeZoneName
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_2000
'
+
datefmt
.
resolvedOptions
().
timeZoneName
);
expect
(
datefmt
.
resolvedOptions
().
timeZoneName
).
assertEqual
(
'
long
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2100
* @tc.name format the year
* @tc.desc check the year
*/
it
(
'
dateTimeFormat_test_2100
'
,
0
,
function
()
{
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_2100
'
+
datefmt
.
resolvedOptions
().
year
);
expect
(
datefmt
.
resolvedOptions
().
year
).
assertEqual
(
'
numeric
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2200
* @tc.name format the weekday
* @tc.desc check the weekday
*/
it
(
'
dateTimeFormat_test_2200
'
,
0
,
function
()
{
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_2200
'
+
datefmt
.
resolvedOptions
().
weekday
);
expect
(
datefmt
.
resolvedOptions
().
weekday
).
assertEqual
(
'
long
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2300
* @tc.name format the hour in zh-CN-u-hc-h12
* @tc.desc check the hour in zh-CN-u-hc-h12
*/
it
(
'
dateTimeFormat_test_2300
'
,
0
,
function
()
{
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_2300
'
+
datefmt
.
resolvedOptions
().
hour
);
expect
(
datefmt
.
resolvedOptions
().
hour
).
assertEqual
(
'
numeric
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2400
* @tc.name format the hour in fr-Latn-FR-u-nu-mong
* @tc.desc check the hour in fr-Latn-FR-u-nu-mong
*/
it
(
'
dateTimeFormat_test_2400
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
fr-Latn-FR-u-nu-mong
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_2400
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
dimanche ᠒᠐ décembre ᠒᠐᠒᠐
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2500
* @tc.name format the hour in zh-CN-u-hc-h12 with matcher
* @tc.desc check the hour in zh-CN-u-hc-h12 with matcher
*/
it
(
'
dateTimeFormat_test_2500
'
,
0
,
function
()
{
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
,
hourCycle
:
'
h24
'
,
numberingSystem
:
'
arab
'
,
hour12
:
true
,
dayPeriod
:
'
short
'
,
formatMatcher
:
'
basic
'
,
localeMatcher
:
'
lookup
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
expect
(
datefmt
.
resolvedOptions
().
locale
).
assertEqual
(
'
zh-CN
'
);
expect
(
datefmt
.
resolvedOptions
().
hourCycle
).
assertEqual
(
'
h24
'
);
expect
(
datefmt
.
resolvedOptions
().
numberingSystem
).
assertEqual
(
'
arab
'
);
expect
(
datefmt
.
resolvedOptions
().
hour12
).
assertTrue
();
expect
(
datefmt
.
resolvedOptions
().
era
).
assertEqual
(
'
short
'
);
expect
(
datefmt
.
resolvedOptions
().
month
).
assertEqual
(
'
long
'
);
expect
(
datefmt
.
resolvedOptions
().
day
).
assertEqual
(
'
numeric
'
);
expect
(
datefmt
.
resolvedOptions
().
minute
).
assertEqual
(
'
2-digit
'
);
expect
(
datefmt
.
resolvedOptions
().
second
).
assertEqual
(
'
numeric
'
);
expect
(
datefmt
.
resolvedOptions
().
dayPeriod
).
assertEqual
(
'
short
'
);
expect
(
datefmt
.
resolvedOptions
().
formatMatcher
).
assertEqual
(
'
basic
'
);
expect
(
datefmt
.
resolvedOptions
().
localeMatcher
).
assertEqual
(
'
lookup
'
);
})
console
.
log
(
'
*************end DateTimeFormatInIntlTest*************
'
);
})}
global/i18n_standard/intljs/src/main/js/test/I18n.test.js
浏览文件 @
40d65e16
...
...
@@ -68,17 +68,6 @@ describe('I18nTest', function () {
expect
(
lang
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0120
* @tc.name getSystemLanguage
* @tc.desc check the getSystemLanguage
*/
it
(
'
i18n_test_0120
'
,
0
,
function
()
{
let
lang
=
I18n
.
System
.
getSystemLanguage
();
console
.
log
(
'
i18n_test_0120
'
+
lang
);
expect
(
lang
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0200
* @tc.name getSystemRegion
...
...
@@ -90,17 +79,6 @@ describe('I18nTest', function () {
expect
(
region
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0220
* @tc.name getSystemRegion
* @tc.desc check the getSystemRegion
*/
it
(
'
i18n_test_0220
'
,
0
,
function
()
{
let
region
=
I18n
.
System
.
getSystemRegion
();
console
.
log
(
'
i18n_test_0220
'
+
region
);
expect
(
region
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0300
* @tc.name getSystemLocale
...
...
@@ -112,90 +90,6 @@ describe('I18nTest', function () {
expect
(
locale
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0320
* @tc.name getSystemLocale
* @tc.desc check the getSystemLocale
*/
it
(
'
i18n_test_0320
'
,
0
,
function
()
{
let
locale
=
I18n
.
System
.
getSystemLocale
();
console
.
log
(
'
i18n_test_0320
'
+
locale
);
expect
(
locale
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0340
* @tc.name is24HourClock
* @tc.desc check the is24HourClock
*/
it
(
'
i18n_test_0340
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
is24HourClock
();
console
.
log
(
'
i18n_test_0340
'
+
value
);
expect
(
value
).
assertFalse
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2110
* @tc.name getSystemLanguages test
* @tc.desc check the getSystemLanguages
*/
it
(
'
i18n_test_2110
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getSystemLanguages
();
let
len
=
value
.
length
;
console
.
log
(
'
i18n_test_2110
'
+
len
);
expect
(
len
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2120
* @tc.name getSystemCountries with en param
* @tc.desc check the getSystemCountries
*/
it
(
'
i18n_test_2120
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getSystemCountries
(
'
en
'
);
let
len
=
value
.
length
;
console
.
log
(
'
i18n_test_2120
'
+
len
);
expect
(
len
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2140
* @tc.name getSystemCountries with en param
* @tc.desc check the getSystemCountries
*/
it
(
'
i18n_test_2140
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getSystemCountries
();
let
len
=
value
.
length
;
console
.
log
(
'
i18n_test_2140
'
+
len
);
expect
(
len
).
assertLarger
(
0
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_2140
'
+
e
.
code
);
console
.
log
(
'
i18n_test_2140
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
401
'
);
expect
(
e
.
message
).
assertEqual
(
'
Check param failed
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2160
* @tc.name getSystemCountries with en param
* @tc.desc check the getSystemCountries
*/
it
(
'
i18n_test_2160
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getSystemCountries
(
12345
);
let
len
=
value
.
length
;
console
.
log
(
'
i18n_test_2160
'
+
len
);
expect
(
len
).
assertLarger
(
0
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_2160
'
+
e
.
code
);
console
.
log
(
'
i18n_test_2160
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2310
* @tc.name isSuggested with zh param
...
...
@@ -240,86 +134,6 @@ describe('I18nTest', function () {
expect
(
value
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2350
* @tc.name isSuggested with zh param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2350
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
isSuggested
(
'
zh
'
);
console
.
log
(
'
i18n_test_2350
'
+
value
);
expect
(
value
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2360
* @tc.name isSuggested with en param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2360
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
isSuggested
(
'
en
'
);
console
.
log
(
'
i18n_test_2360
'
+
value
);
expect
(
value
).
assertFalse
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2370
* @tc.name isSuggested with zh-CN param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2370
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
isSuggested
(
'
zh
'
,
'
CN
'
);
console
.
log
(
'
i18n_test_2370
'
+
value
);
expect
(
value
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2380
* @tc.name isSuggested with en-US param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2380
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
isSuggested
(
'
en
'
,
'
US
'
);
console
.
log
(
'
i18n_test_2380
'
+
value
);
expect
(
value
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2390
* @tc.name isSuggested with en-US param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2390
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
isSuggested
();
console
.
log
(
'
i18n_test_2390
'
+
value
);
expect
(
value
).
assertTrue
();
}
catch
(
e
){
console
.
log
(
'
i18n_test_2390
'
+
e
.
code
);
console
.
log
(
'
i18n_test_2390
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
401
'
);
expect
(
e
.
message
).
assertEqual
(
'
Check param failed
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2391
* @tc.name isSuggested with en-US param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2391
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
isSuggested
(
12345
);
console
.
log
(
'
i18n_test_2391
'
+
value
);
expect
(
value
).
assertTrue
();
}
catch
(
e
){
console
.
log
(
'
i18n_test_2391
'
+
e
.
code
);
console
.
log
(
'
i18n_test_2391
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3800
* @tc.name getDisplayCountry with zh-Hans-CN and en-US and true param
...
...
@@ -408,144 +222,6 @@ describe('I18nTest', function () {
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4310
* @tc.name getDisplayCountry with zh-Hans-CN and en-US and true param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4310
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_4310
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4320
* @tc.name getDisplayCountry with zh-Hans-CN and en-US and undefined param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4320
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
'
en-US
'
,
undefined
);
console
.
log
(
'
i18n_test_4320
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4321
* @tc.name getDisplayCountry with zh-Hans-CN and en-US and null param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4321
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
'
en-US
'
,
null
);
console
.
log
(
'
i18n_test_4321
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4330
* @tc.name getDisplayCountry with zh and en-US and true param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4330
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_4330
'
+
value
);
expect
(
value
).
assertEqual
(
''
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_4330
'
+
e
.
code
);
console
.
log
(
'
i18n_test_4330
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4340
* @tc.name getDisplayCountry with zh-CN and en-US and true param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4340
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-CN
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_4340
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4350
* @tc.name getDisplayCountry with zh-Hans and en-US and true param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4350
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_4350
'
+
value
);
expect
(
value
).
assertEqual
(
''
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_4350
'
+
e
.
code
);
console
.
log
(
'
i18n_test_4350
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4360
* @tc.name getDisplayCountry with zh-Hans-CN and en-US and false param
* @tc.desc check the language
*/
it
(
'
i18n_test_4360
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
'
en-US
'
,
false
);
console
.
log
(
'
i18n_test_4360
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4370
* @tc.name getDisplayCountry with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_4370
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
'
en-US
'
);
console
.
log
(
'
i18n_test_4370
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4380
* @tc.name getDisplayCountry with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_4380
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
);
console
.
log
(
'
i18n_test_4380
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_4380
'
+
e
.
code
);
console
.
log
(
'
i18n_test_4380
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
401
'
);
expect
(
e
.
message
).
assertEqual
(
'
Check param failed
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4390
* @tc.name getDisplayCountry with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_4390
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
12345
);
console
.
log
(
'
i18n_test_4390
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_4390
'
+
e
.
code
);
console
.
log
(
'
i18n_test_4390
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4400
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US and true param
...
...
@@ -645,141 +321,6 @@ describe('I18nTest', function () {
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5010
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US and true param
* @tc.desc check the language
*/
it
(
'
i18n_test_5010
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_5010
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5020
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US and undefined param
* @tc.desc check the language
*/
it
(
'
i18n_test_5020
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-US
'
,
undefined
);
console
.
log
(
'
i18n_test_5020
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5021
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US and null param
* @tc.desc check the language
*/
it
(
'
i18n_test_5021
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-US
'
,
null
);
console
.
log
(
'
i18n_test_5021
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5030
* @tc.name getDisplayLanguage with zh-Hans-CN and en-GB and true param
* @tc.desc check the language
*/
it
(
'
i18n_test_5030
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-GB
'
,
true
);
console
.
log
(
'
i18n_test_5030
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5040
* @tc.name getDisplayLanguage with zh and en-US and true param
* @tc.desc check the language
*/
it
(
'
i18n_test_5040
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_5040
'
+
value
);
expect
(
value
).
assertEqual
(
'
Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5050
* @tc.name getDisplayLanguage with zh-CN and en-US and true param
* @tc.desc check the language
*/
it
(
'
i18n_test_5050
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-CN
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_5050
'
+
value
);
expect
(
value
).
assertEqual
(
'
Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5060
* @tc.name getDisplayLanguage with zh-Hans and en-US and true param
* @tc.desc check the language
*/
it
(
'
i18n_test_5060
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_5060
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5070
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US and false param
* @tc.desc check the language
*/
it
(
'
i18n_test_5070
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-US
'
,
false
);
console
.
log
(
'
i18n_test_5070
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5080
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_5080
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-US
'
);
console
.
log
(
'
i18n_test_5080
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5090
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_5090
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
);
console
.
log
(
'
i18n_test_5090
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_5090
'
+
e
.
code
);
console
.
log
(
'
i18n_test_5090
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
401
'
);
expect
(
e
.
message
).
assertEqual
(
'
Check param failed
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5091
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_5091
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
12345
);
console
.
log
(
'
i18n_test_5091
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_5091
'
+
e
.
code
);
console
.
log
(
'
i18n_test_5091
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/**
* @tc.number SUB_GLOBAL_I18N_JS_8800
* @tc.name test isRTL interface with zh-CN param
...
...
global/i18n_standard/intljs/src/main/js/test/Lang.test.js
浏览文件 @
40d65e16
...
...
@@ -138,18 +138,6 @@ describe('LangTest', function () {
expect
(
value
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0110
* @tc.name test the getPreferredLanguageList interface with default value
* @tc.desc check the value of getPreferredLanguageList method
*/
it
(
'
i18n_test_preferredlanguage_0110
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0110
'
+
'
start
'
);
let
value
=
I18n
.
System
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0110
'
+
value
);
expect
(
value
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0120
* @tc.name test the addPreferredLanguage interface
...
...
@@ -211,26 +199,6 @@ describe('LangTest', function () {
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_1020
* @tc.name test the getFirstPreferredLanguage interface
* @tc.desc check the value of getFirstPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_1020
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_1020
'
+
'
start
'
);
let
value
=
I18n
.
System
.
getFirstPreferredLanguage
();
console
.
log
(
'
i18n_test_preferredlanguage_1020
'
+
value
);
let
list
=
I18n
.
System
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_1020
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
if
(
list
[
0
]
==
'
zh-Hans
'
){
expect
(
value
).
assertEqual
(
'
zh-Hans
'
);
}
else
if
(
list
[
0
]
==
'
en
'
){
expect
(
value
).
assertEqual
(
'
en
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_1100
* @tc.name test the getAppPreferredLanguage interface
...
...
@@ -243,18 +211,6 @@ describe('LangTest', function () {
expect
(
value
).
assertContain
(
'
zh
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_1120
* @tc.name test the getAppPreferredLanguage interface
* @tc.desc check the value of getAppPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_1120
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_1120
'
+
'
start
'
);
let
value
=
I18n
.
System
.
getAppPreferredLanguage
();
console
.
log
(
'
i18n_test_preferredlanguage_1120
'
+
value
);
expect
(
value
).
assertContain
(
'
zh
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_TRANSFER_0100
* @tc.name transfer from lower to upper
...
...
@@ -303,16 +259,5 @@ describe('LangTest', function () {
expect
(
value
).
assertEqual
(
'
the sky is in blue-style!
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_LOCALDIGIT_0100
* @tc.name test getUsingLocalDigit method
* @tc.desc get the getUsingLocalDigit value
*/
it
(
'
localdigit_test_0100
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getUsingLocalDigit
();
console
.
log
(
'
localdigit_test_0100
'
+
value
);
expect
(
value
).
assertFalse
();
})
console
.
log
(
'
*************end LangTest*************
'
);
})}
global/i18n_standard/intljs/src/main/js/test/List.test.js
浏览文件 @
40d65e16
...
...
@@ -19,7 +19,6 @@ import CharacterInI18nTest from './CharacterInI18n.test.js'
import
I18nTest
from
'
./I18n.test.js
'
import
I18nUtilInI18nTest
from
'
./I18nUtilInI18n.test.js
'
import
IndexUtilInI18nTest
from
'
./IndexUtilInI18n.test.js
'
import
intlTest
from
'
./Intl.test.js
'
import
NormalizerInI18nTest
from
'
./NormalizerInI18n.test.js
'
import
PhoneNumberFormatInI18nTest
from
'
./PhoneNumberFormatInI18n.test.js
'
import
LangTest
from
'
./Lang.test.js
'
...
...
@@ -28,7 +27,12 @@ import TimezoneInI18nTest from './TimezoneInI18n.test.js'
import
TransliteratorInI18nTest
from
'
./TransliteratorInI18n.test.js
'
import
UnicodeInI18nTest
from
'
./UnicodeInI18n.test.js
'
import
UtilInI18nTest
from
'
./UtilInI18n.test.js
'
import
CollatorInIntlTest
from
'
./CollatorInIntl.test.js
'
import
DateTimeFormatInIntlTest
from
'
./DateTimeFormatInIntl.test.js
'
import
LocaleInIntlTest
from
'
./LocaleInIntl.test.js
'
import
NumberFormatInIntlTest
from
'
./NumberFormatInIntl.test.js
'
import
PluralRulesInIntlTest
from
'
./PluralRulesInIntl.test.js
'
import
RelativeTimeFormatInIntlTest
from
'
./RelativeTimeFormatInIntl.test.js
'
export
default
function
testsuite
()
{
BreakIteratorInI18nTest
()
CalendarInI18nTest
()
...
...
@@ -36,7 +40,6 @@ CharacterInI18nTest()
I18nTest
()
I18nUtilInI18nTest
()
IndexUtilInI18nTest
()
intlTest
()
NormalizerInI18nTest
()
PhoneNumberFormatInI18nTest
()
LangTest
()
...
...
@@ -45,5 +48,10 @@ TimezoneInI18nTest()
TransliteratorInI18nTest
()
UnicodeInI18nTest
()
UtilInI18nTest
()
CollatorInIntlTest
()
DateTimeFormatInIntlTest
()
LocaleInIntlTest
()
NumberFormatInIntlTest
()
PluralRulesInIntlTest
()
RelativeTimeFormatInIntlTest
()
}
global/i18n_standard/intljs/src/main/js/test/Intl.test.js
→
global/i18n_standard/intljs/src/main/js/test/
NumberFormatIn
Intl.test.js
浏览文件 @
40d65e16
/*
* Copyright (C) 202
1
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -12,33 +12,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
I18n
from
'
@ohos.i18n
'
import
Intl
from
'
@ohos.intl
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
i
ntlTest
()
{
describe
(
'
i
ntlTest
'
,
function
()
{
console
.
log
(
'
*************start IntlTest*************
'
);
export
default
function
NumberFormatInI
ntlTest
()
{
describe
(
'
NumberFormatInI
ntlTest
'
,
function
()
{
console
.
log
(
'
*************start
NumberFormatIn
IntlTest*************
'
);
let
hour
=
I18n
.
is24HourClock
();
let
hour
=
I18n
.
System
.
is24HourClock
();
console
.
log
(
'
init 24 hour clock value
'
+
hour
);
/* *
* execute this step before all testcases
*/
beforeAll
(
function
(){
console
.
log
(
'
step before all cases in
intl
.
'
+
'
24hour:
'
+
I18n
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
getSystemLocale
());
console
.
log
(
'
step before all cases in
I18n
.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* execute this step before every testcase
*/
beforeEach
(
function
(){
console
.
log
(
'
step before every case in
intl
.
'
);
console
.
log
(
'
step before every case in
I18n
.
'
);
})
/* *
...
...
@@ -52,403 +51,10 @@ describe('intlTest', function () {
* execute this step after all testcases
*/
afterAll
(
function
(){
console
.
log
(
'
step after all cases in intl.
'
+
'
24hour:
'
+
I18n
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
getSystemLocale
());
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0100
* @tc.name format the datetime with en-GB locale
* @tc.desc check the datetime is not null
*/
it
(
'
dateTimeFormat_test_0100
'
,
0
,
function
()
{
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
expect
(
datefmt
!==
null
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0120
* @tc.name format the datetime with en-GB locale
* @tc.desc check the datetime is not null
*/
it
(
'
dateTimeFormat_test_0120
'
,
0
,
function
()
{
let
datefmt
=
new
Intl
.
DateTimeFormat
();
expect
(
datefmt
!==
null
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0200
* @tc.name format the date with zh locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0200
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh
'
);
console
.
log
(
'
dateTimeFormat_test_0200
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2021
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0220
* @tc.name format the date with zh locale and undefined options
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0220
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh
'
,
undefined
);
console
.
log
(
'
dateTimeFormat_test_0220
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2021
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0240
* @tc.name format the date with zh locale and null options
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0240
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh
'
,
null
);
console
.
log
(
'
dateTimeFormat_test_0240
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2021
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0300
* @tc.name format the date with en locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0300
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en
'
);
console
.
log
(
'
dateTimeFormat_test_0300
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
21
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0310
* @tc.name format the date with en-US locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0310
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-US
'
);
console
.
log
(
'
dateTimeFormat_test_0310
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
21
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0320
* @tc.name format the date with en-GB locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0320
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
console
.
log
(
'
dateTimeFormat_test_0320
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2021
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0400
* @tc.name format the date with aa locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_0400
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
aa
'
);
let
value
=
datefmt
.
format
(
date
);
console
.
log
(
'
dateTimeFormat_test_0400
'
+
value
);
expect
(
value
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0500
* @tc.name format the hour with ban and zh locale
* @tc.desc check the hour with ban and zh locale
*/
it
(
'
dateTimeFormat_test_0500
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
([
'
ban
'
,
'
zh
'
],
option
);
console
.
log
(
'
dateTimeFormat_test_0500
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
2020年12月20日星期日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0600
* @tc.name format the hour with en and zh locale
* @tc.desc check the hour with en and zh locale
*/
it
(
'
dateTimeFormat_test_0600
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
([
'
en
'
,
'
zh
'
],
option
);
console
.
log
(
'
dateTimeFormat_test_0600
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
Sunday, December 20, 2020
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0700
* @tc.name format the hour with en and ban locale
* @tc.desc check the hour with en and ban locale
*/
it
(
'
dateTimeFormat_test_0700
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
([
'
en
'
,
'
ban
'
],
option
);
console
.
log
(
'
dateTimeFormat_test_0700
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
Sunday, December 20, 2020
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0800
* @tc.name format the hour without correct locale
* @tc.desc check the hour without correct locale
*/
it
(
'
dateTimeFormat_test_0800
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
([
'
abc
'
,
'
ban
'
],
option
);
console
.
log
(
'
dateTimeFormat_test_0800
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2020
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0900
* @tc.name format the date with full datestyle and mediu timestyle
* @tc.desc check the date with full datestyle and mediu timestyle
*/
it
(
'
dateTimeFormat_test_0900
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
,
timeStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-Hans-CN
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_0900
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2020年12月20日星期日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1000
* @tc.name format the date dateStyle with long style
* @tc.desc check the dateStyle with long style
*/
it
(
'
dateTimeFormat_test_1000
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
long
'
,
timeStyle
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1000
'
+
datefmt
.
resolvedOptions
().
dateStyle
);
expect
(
datefmt
.
resolvedOptions
().
dateStyle
).
assertEqual
(
'
long
'
);
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2020年12月20日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1100
* @tc.name format the date dateStyle with medium style
* @tc.desc check the dateStyle with medium style
*/
it
(
'
dateTimeFormat_test_1100
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
medium
'
,
timeStyle
:
'
medium
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1100
'
+
datefmt
.
resolvedOptions
().
dateStyle
);
expect
(
datefmt
.
resolvedOptions
().
dateStyle
).
assertEqual
(
'
medium
'
);
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2020年12月20日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1200
* @tc.name format the date dateStyle with short style
* @tc.desc check the dateStyle with short style
*/
it
(
'
dateTimeFormat_test_1200
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
short
'
,
timeStyle
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1200
'
+
datefmt
.
resolvedOptions
().
dateStyle
);
expect
(
datefmt
.
resolvedOptions
().
dateStyle
).
assertEqual
(
'
short
'
);
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
2020/12/20
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1300
* @tc.name format the date with daterange
* @tc.desc check the daterange
*/
it
(
'
dateTimeFormat_test_1300
'
,
0
,
function
()
{
let
startdate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
enddate
=
new
Date
(
2020
,
11
,
21
,
14
,
23
,
16
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
console
.
log
(
'
dateTimeFormat_test_1300
'
+
datefmt
.
formatRange
(
startdate
,
enddate
));
expect
(
datefmt
.
formatRange
(
startdate
,
enddate
)).
assertEqual
(
'
20/12/2020 – 21/12/2020
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1400
* @tc.name format the date with daterange when the start and end date is equal
* @tc.desc check the daterange when the start and end date is equal
*/
it
(
'
dateTimeFormat_test_1400
'
,
0
,
function
()
{
let
startdate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
enddate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
console
.
log
(
'
dateTimeFormat_test_1400
'
+
datefmt
.
formatRange
(
startdate
,
enddate
));
expect
(
datefmt
.
formatRange
(
startdate
,
enddate
)).
assertEqual
(
'
20/12/2020
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1500
* @tc.name format the year、month、day、weekday
* @tc.desc check the year、month、day、weekday
*/
it
(
'
dateTimeFormat_test_1500
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
weekday
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
ja
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1500
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
2020年12月20日日曜日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1600
* @tc.name format the timerange with year、month、day、weekday
* @tc.desc check the timerange with year、month、day、weekday
*/
it
(
'
dateTimeFormat_test_1600
'
,
0
,
function
()
{
let
startdate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
enddate
=
new
Date
(
2021
,
4
,
5
,
10
,
5
,
3
);
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
weekday
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1600
'
+
datefmt
.
formatRange
(
startdate
,
enddate
));
expect
(
datefmt
.
formatRange
(
startdate
,
enddate
)).
assertEqual
(
'
Sunday, December 20, 2020 – Wednesday, May 5, 2021
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1700
* @tc.name format the hour&minute&second
* @tc.desc check the hour&minute&second
*/
it
(
'
dateTimeFormat_test_1700
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1700
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertContain
(
'
公元2020年12月20日星期日
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1800
* @tc.name format the timeZone
* @tc.desc check the timeZone
*/
it
(
'
dateTimeFormat_test_1800
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
3
,
14
,
15
,
5
,
3
);
let
option
=
{
timeZone
:
'
America/Los_Angeles
'
,
timeZoneName
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1800
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
).
indexOf
(
'
北美太平洋夏令时间
'
)
!==
-
1
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_1900
* @tc.name format the America/Los_Angeles timeZone
* @tc.desc check the America/Los_Angeles timeZone
*/
it
(
'
dateTimeFormat_test_1900
'
,
0
,
function
()
{
let
option
=
{
timeZone
:
'
America/Los_Angeles
'
,
timeZoneName
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_1900
'
+
datefmt
.
resolvedOptions
().
timeZone
);
expect
(
datefmt
.
resolvedOptions
().
timeZone
).
assertEqual
(
'
America/Los_Angeles
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2000
* @tc.name format the America/Los_Angeles timeZoneName
* @tc.desc check the America/Los_Angeles timeZoneName
*/
it
(
'
dateTimeFormat_test_2000
'
,
0
,
function
()
{
let
option
=
{
timeZone
:
'
America/Los_Angeles
'
,
timeZoneName
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_2000
'
+
datefmt
.
resolvedOptions
().
timeZoneName
);
expect
(
datefmt
.
resolvedOptions
().
timeZoneName
).
assertEqual
(
'
long
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2100
* @tc.name format the year
* @tc.desc check the year
*/
it
(
'
dateTimeFormat_test_2100
'
,
0
,
function
()
{
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_2100
'
+
datefmt
.
resolvedOptions
().
year
);
expect
(
datefmt
.
resolvedOptions
().
year
).
assertEqual
(
'
numeric
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2200
* @tc.name format the weekday
* @tc.desc check the weekday
*/
it
(
'
dateTimeFormat_test_2200
'
,
0
,
function
()
{
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_2200
'
+
datefmt
.
resolvedOptions
().
weekday
);
expect
(
datefmt
.
resolvedOptions
().
weekday
).
assertEqual
(
'
long
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2300
* @tc.name format the hour in zh-CN-u-hc-h12
* @tc.desc check the hour in zh-CN-u-hc-h12
*/
it
(
'
dateTimeFormat_test_2300
'
,
0
,
function
()
{
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_2300
'
+
datefmt
.
resolvedOptions
().
hour
);
expect
(
datefmt
.
resolvedOptions
().
hour
).
assertEqual
(
'
numeric
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2400
* @tc.name format the hour in fr-Latn-FR-u-nu-mong
* @tc.desc check the hour in fr-Latn-FR-u-nu-mong
*/
it
(
'
dateTimeFormat_test_2400
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
fr-Latn-FR-u-nu-mong
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_2400
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
dimanche ᠒᠐ décembre ᠒᠐᠒᠐
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_2500
* @tc.name format the hour in zh-CN-u-hc-h12 with matcher
* @tc.desc check the hour in zh-CN-u-hc-h12 with matcher
*/
it
(
'
dateTimeFormat_test_2500
'
,
0
,
function
()
{
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
,
hourCycle
:
'
h24
'
,
numberingSystem
:
'
arab
'
,
hour12
:
true
,
dayPeriod
:
'
short
'
,
formatMatcher
:
'
basic
'
,
localeMatcher
:
'
lookup
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
expect
(
datefmt
.
resolvedOptions
().
locale
).
assertEqual
(
'
zh-CN
'
);
expect
(
datefmt
.
resolvedOptions
().
hourCycle
).
assertEqual
(
'
h24
'
);
expect
(
datefmt
.
resolvedOptions
().
numberingSystem
).
assertEqual
(
'
arab
'
);
expect
(
datefmt
.
resolvedOptions
().
hour12
).
assertTrue
();
expect
(
datefmt
.
resolvedOptions
().
era
).
assertEqual
(
'
short
'
);
expect
(
datefmt
.
resolvedOptions
().
month
).
assertEqual
(
'
long
'
);
expect
(
datefmt
.
resolvedOptions
().
day
).
assertEqual
(
'
numeric
'
);
expect
(
datefmt
.
resolvedOptions
().
minute
).
assertEqual
(
'
2-digit
'
);
expect
(
datefmt
.
resolvedOptions
().
second
).
assertEqual
(
'
numeric
'
);
expect
(
datefmt
.
resolvedOptions
().
dayPeriod
).
assertEqual
(
'
short
'
);
expect
(
datefmt
.
resolvedOptions
().
formatMatcher
).
assertEqual
(
'
basic
'
);
expect
(
datefmt
.
resolvedOptions
().
localeMatcher
).
assertEqual
(
'
lookup
'
);
console
.
log
(
'
step after all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
...
...
@@ -865,444 +471,5 @@ describe('intlTest', function () {
expect
(
numfmt
.
resolvedOptions
().
useGrouping
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2600
* @tc.name get PluralRules
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2600
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
();
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2600
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2700
* @tc.name get PluralRules with zh locale
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2700
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
);
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2700
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2720
* @tc.name get PluralRules with zh locale and undefined options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2720
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
undefined
);
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2720
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2740
* @tc.name get PluralRules with zh locale and null options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2740
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
null
);
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2740
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2800
* @tc.name get PluralRules with zh locale and ordinal type
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2800
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
type
'
:
'
ordinal
'
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2800
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2900
* @tc.name get PluralRules with zh locale and loolup localeMatcher
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2900
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
localeMatcher
'
:
'
lookup
'
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2900
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3000
* @tc.name get PluralRules with zh locale and minimumIntegerDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3000
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
minimumIntegerDigits
'
:
10
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3000
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3100
* @tc.name get PluralRules with zh locale and minimumFractionDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3100
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
minimumFractionDigits
'
:
11
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3100
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3200
* @tc.name get PluralRules with zh locale and maximumFractionDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3200
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
maximumFractionDigits
'
:
'
lookup
'
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3200
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3300
* @tc.name get PluralRules with zh locale and minimumSignificantDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3300
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
minimumSignificantDigits
'
:
10
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3300
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3400
* @tc.name get PluralRules with zh locale and maximumSignificantDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3400
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
maximumSignificantDigits
'
:
11
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3400
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3500
* @tc.name compare two different strings
* @tc.desc check the compare result
*/
it
(
'
collator_test_3500
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
();
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3500
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3510
* @tc.name compare the same strings
* @tc.desc check the compare result
*/
it
(
'
collator_test_3510
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
();
let
value
=
coll
.
compare
(
'
a
'
,
'
a
'
);
console
.
log
(
'
collator_test_3100
'
+
value
);
expect
(
value
).
assertEqual
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3520
* @tc.name compare two different strings and return positive value
* @tc.desc check the compare result
*/
it
(
'
collator_test_3520
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
();
let
value
=
coll
.
compare
(
'
b
'
,
'
a
'
);
console
.
log
(
'
collator_test_3200
'
+
value
);
expect
(
value
).
assertEqual
(
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3600
* @tc.name compare two different strings with zh locale
* @tc.desc check the compare result
*/
it
(
'
collator_test_3600
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
);
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3600
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3620
* @tc.name compare two different strings with zh locale and undefined options
* @tc.desc check the compare result
*/
it
(
'
collator_test_3620
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
undefined
);
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3620
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3640
* @tc.name compare two different strings with zh locale and null options
* @tc.desc check the compare result
*/
it
(
'
collator_test_3640
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
null
);
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3640
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3700
* @tc.name compare two different strings with zh locale and eor collation
* @tc.desc check the compare result
*/
it
(
'
collator_test_3700
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
collation
'
:
'
eor
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3700
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
collation
).
assertEqual
(
'
eor
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3800
* @tc.name compare two different strings with zh locale and base sensitivity
* @tc.desc check the compare result
*/
it
(
'
collator_test_3800
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
sensitivity
'
:
'
base
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3800
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
sensitivity
).
assertEqual
(
'
base
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3900
* @tc.name compare two different strings with zh locale and upper caseFirst
* @tc.desc check the compare result
*/
it
(
'
collator_test_3900
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
caseFirst
'
:
'
upper
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3900
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
caseFirst
).
assertEqual
(
'
upper
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4000
* @tc.name compare two different strings with zh locale and true numeric
* @tc.desc check the compare result
*/
it
(
'
collator_test_4000
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
numeric
'
:
true
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4000
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
numeric
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4100
* @tc.name compare two different strings with zh locale and true ignorePunctuation
* @tc.desc check the compare result
*/
it
(
'
collator_test_4100
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
ignorePunctuation
'
:
true
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4100
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
ignorePunctuation
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4200
* @tc.name compare two different strings with zh locale and sort usage
* @tc.desc check the compare result
*/
it
(
'
collator_test_4200
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
usage
'
:
'
sort
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4200
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
usage
).
assertEqual
(
'
sort
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4300
* @tc.name compare the string with localeMatcher options
* @tc.desc check the compare result
*/
it
(
'
collator_test_4300
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
localeMatcher
'
:
'
lookup
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4300
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
localeMatcher
).
assertEqual
(
'
lookup
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0100
* @tc.name format the relativetime with 100 second
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0100
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0100
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
();
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0100
'
+
value
);
expect
(
value
).
assertContain
(
'
100
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0200
* @tc.name format the relativetime with 100 second in en
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0200
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0200
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0200
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 seconds
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0220
* @tc.name format the relativetime with 100 second in en and undefined options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0220
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0220
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
undefined
);
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0220
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 seconds
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0240
* @tc.name format the relativetime with 100 second in en and null options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0240
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0240
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
null
);
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0240
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 seconds
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0300
* @tc.name format the relativetime with 100 second in narrow style
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0300
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0300
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
{
style
:
'
narrow
'
});
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0300
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 sec.
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0400
* @tc.name format the relativetime with 100 second, get the formatToParts value
* @tc.desc check the formatToParts value
*/
it
(
'
i18n_test_relativetimeformat_0400
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0400
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
formatToParts
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0400
'
+
value
[
0
].
value
+
'
value
'
);
expect
(
value
[
0
].
value
).
assertEqual
(
'
in
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0500
* @tc.name format the relativetime, get the locale options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0500
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0500
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0500
'
+
value
);
expect
(
value
.
locale
).
assertEqual
(
'
en
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0600
* @tc.name format the relativetime, get the style options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0600
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0600
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0600
'
+
value
);
expect
(
value
.
style
).
assertEqual
(
'
long
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0700
* @tc.name format the relativetime, get the numeric options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0700
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0700
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0700
'
+
value
);
expect
(
value
.
numeric
).
assertEqual
(
'
always
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0800
* @tc.name format the relativetime, get the numberingSystem options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0800
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0800
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0800
'
+
value
.
numberingSystem
);
expect
(
value
.
numberingSystem
).
assertEqual
(
'
latn
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0900
* @tc.name format the relativetime with localeMatcher options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0900
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0900
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
{
localeMatcher
:
'
best fit
'
,
numeric
:
'
auto
'
,
style
:
'
narrow
'
});
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0900
'
+
value
);
expect
(
value
.
numeric
).
assertEqual
(
'
auto
'
);
expect
(
value
.
style
).
assertEqual
(
'
narrow
'
);
})
console
.
log
(
'
*************end IntlTest*************
'
);
console
.
log
(
'
*************end NumberFormatInIntlTest*************
'
);
})}
global/i18n_standard/intljs/src/main/js/test/PluralRulesInIntl.test.js
0 → 100644
浏览文件 @
40d65e16
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
I18n
from
'
@ohos.i18n
'
import
Intl
from
'
@ohos.intl
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
PluralRulesInIntlTest
()
{
describe
(
'
PluralRulesInIntlTest
'
,
function
()
{
console
.
log
(
'
*************start PluralRulesInIntlTest*************
'
);
let
hour
=
I18n
.
System
.
is24HourClock
();
console
.
log
(
'
init 24 hour clock value
'
+
hour
);
/* *
* execute this step before all testcases
*/
beforeAll
(
function
(){
console
.
log
(
'
step before all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* execute this step before every testcase
*/
beforeEach
(
function
(){
console
.
log
(
'
step before every case in I18n.
'
);
})
/* *
* execute this step after every testcase
*/
afterEach
(
function
(){
console
.
log
(
'
step after every case in I18n.
'
);
})
/* *
* execute this step after all testcases
*/
afterAll
(
function
(){
console
.
log
(
'
step after all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2600
* @tc.name get PluralRules
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2600
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
();
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2600
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2700
* @tc.name get PluralRules with zh locale
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2700
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
);
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2700
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2720
* @tc.name get PluralRules with zh locale and undefined options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2720
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
undefined
);
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2720
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2740
* @tc.name get PluralRules with zh locale and null options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2740
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
null
);
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2740
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2800
* @tc.name get PluralRules with zh locale and ordinal type
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2800
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
type
'
:
'
ordinal
'
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2800
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2900
* @tc.name get PluralRules with zh locale and loolup localeMatcher
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2900
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
localeMatcher
'
:
'
lookup
'
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2900
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3000
* @tc.name get PluralRules with zh locale and minimumIntegerDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3000
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
minimumIntegerDigits
'
:
10
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3000
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3100
* @tc.name get PluralRules with zh locale and minimumFractionDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3100
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
minimumFractionDigits
'
:
11
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3100
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3200
* @tc.name get PluralRules with zh locale and maximumFractionDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3200
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
maximumFractionDigits
'
:
'
lookup
'
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3200
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3300
* @tc.name get PluralRules with zh locale and minimumSignificantDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3300
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
minimumSignificantDigits
'
:
10
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3300
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3400
* @tc.name get PluralRules with zh locale and maximumSignificantDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3400
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
maximumSignificantDigits
'
:
11
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3400
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
console
.
log
(
'
*************end PluralRulesInIntlTest*************
'
);
})}
global/i18n_standard/intljs/src/main/js/test/RelativeTimeFormatInIntl.test.js
0 → 100644
浏览文件 @
40d65e16
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
I18n
from
'
@ohos.i18n
'
import
Intl
from
'
@ohos.intl
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
RelativeTimeFormatInIntlTest
()
{
describe
(
'
RelativeTimeFormatInIntlTest
'
,
function
()
{
console
.
log
(
'
*************start RelativeTimeFormatInIntlTest*************
'
);
let
hour
=
I18n
.
System
.
is24HourClock
();
console
.
log
(
'
init 24 hour clock value
'
+
hour
);
/* *
* execute this step before all testcases
*/
beforeAll
(
function
(){
console
.
log
(
'
step before all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* execute this step before every testcase
*/
beforeEach
(
function
(){
console
.
log
(
'
step before every case in I18n.
'
);
})
/* *
* execute this step after every testcase
*/
afterEach
(
function
(){
console
.
log
(
'
step after every case in I18n.
'
);
})
/* *
* execute this step after all testcases
*/
afterAll
(
function
(){
console
.
log
(
'
step after all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0100
* @tc.name format the relativetime with 100 second
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0100
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0100
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
();
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0100
'
+
value
);
expect
(
value
).
assertContain
(
'
100
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0200
* @tc.name format the relativetime with 100 second in en
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0200
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0200
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0200
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 seconds
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0220
* @tc.name format the relativetime with 100 second in en and undefined options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0220
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0220
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
undefined
);
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0220
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 seconds
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0240
* @tc.name format the relativetime with 100 second in en and null options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0240
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0240
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
null
);
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0240
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 seconds
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0300
* @tc.name format the relativetime with 100 second in narrow style
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0300
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0300
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
{
style
:
'
narrow
'
});
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0300
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 sec.
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0400
* @tc.name format the relativetime with 100 second, get the formatToParts value
* @tc.desc check the formatToParts value
*/
it
(
'
i18n_test_relativetimeformat_0400
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0400
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
formatToParts
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0400
'
+
value
[
0
].
value
+
'
value
'
);
expect
(
value
[
0
].
value
).
assertEqual
(
'
in
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0500
* @tc.name format the relativetime, get the locale options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0500
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0500
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0500
'
+
value
);
expect
(
value
.
locale
).
assertEqual
(
'
en
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0600
* @tc.name format the relativetime, get the style options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0600
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0600
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0600
'
+
value
);
expect
(
value
.
style
).
assertEqual
(
'
long
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0700
* @tc.name format the relativetime, get the numeric options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0700
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0700
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0700
'
+
value
);
expect
(
value
.
numeric
).
assertEqual
(
'
always
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0800
* @tc.name format the relativetime, get the numberingSystem options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0800
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0800
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0800
'
+
value
.
numberingSystem
);
expect
(
value
.
numberingSystem
).
assertEqual
(
'
latn
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0900
* @tc.name format the relativetime with localeMatcher options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0900
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0900
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
{
localeMatcher
:
'
best fit
'
,
numeric
:
'
auto
'
,
style
:
'
narrow
'
});
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0900
'
+
value
);
expect
(
value
.
numeric
).
assertEqual
(
'
auto
'
);
expect
(
value
.
style
).
assertEqual
(
'
narrow
'
);
})
console
.
log
(
'
*************end RelativeTimeFormatInIntlTest*************
'
);
})}
鸿蒙社区
@harmonycommunity
mentioned in commit
99d0ab82
·
5月 31, 2023
mentioned in commit
99d0ab82
mentioned in commit 99d0ab829d17b3aa586ff880efafb431e6822da2
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录