From 74c0b88d5c695238c8418bf5eb5dfa0e423b7fbc Mon Sep 17 00:00:00 2001 From: y00314596 Date: Mon, 11 Apr 2022 17:37:50 +0800 Subject: [PATCH] fixed 0a1eacb from https://gitee.com/yangqing3/xts_acts/pulls/2975 add by yangqing3@huawei.com Signed-off-by: y00314596 --- .../src/main/js/default/test/I18n.test.js | 16 ++++ .../src/main/js/default/test/Intl.test.js | 78 +++++++++++++++---- 2 files changed, 81 insertions(+), 13 deletions(-) diff --git a/global/i18n_standard/intljs/src/main/js/default/test/I18n.test.js b/global/i18n_standard/intljs/src/main/js/default/test/I18n.test.js index 6b4c9e05c..dede972e8 100755 --- a/global/i18n_standard/intljs/src/main/js/default/test/I18n.test.js +++ b/global/i18n_standard/intljs/src/main/js/default/test/I18n.test.js @@ -1625,6 +1625,22 @@ describe('I18nTest', function () { 'en-US', 'medium'); console.log('i18n_test_9200 ' + value); + expect(value).assertEqual('236.588 L'); + }) + + /** + * @tc.number SUB_GLOBAL_I18N_JS_9250 + * @tc.name test unitConvert interface from cup to liter unit with narrow style + * @tc.desc get the unitConvert value + */ + it('i18n_test_9250', 0, function () { + console.log('i18n_test_9250 ' + 'start'); + let value = I18n.Util.unitConvert({unit: 'cup', measureSystem: 'US'}, + {unit: 'liter', measureSystem: 'SI'}, + 1000, + 'en-US', + 'narrow'); + console.log('i18n_test_9250 ' + value); expect(value).assertEqual('236.588L'); }) diff --git a/global/i18n_standard/intljs/src/main/js/default/test/Intl.test.js b/global/i18n_standard/intljs/src/main/js/default/test/Intl.test.js index eb2203d70..47a68f189 100755 --- a/global/i18n_standard/intljs/src/main/js/default/test/Intl.test.js +++ b/global/i18n_standard/intljs/src/main/js/default/test/Intl.test.js @@ -1095,19 +1095,6 @@ describe('intlTest', function () { expect(numfmt.format(123456.789)).assertEqual('+¥123,457'); }) - /* * - * @tc.number SUB_GLOBAL_INTL_JS_NUMBER_2250 - * @tc.name format the number with unitUsage - * @tc.desc check the number with unitUsage - */ - it('formatNumber_test_2250', 0, function () { - let numfmt = new Intl.NumberFormat('zh-CN', { style: 'unit', unit: 'meter', - unitDisplay: 'long', unitUsage: 'length-road' }); - console.log('formatNumber_test_2250 ' + numfmt.format(123456.789)); - expect(numfmt.format(123456.789)).assertEqual('123,456.789米'); - expect(numfmt.resolvedOptions().unitUsage).assertEqual('length-road'); - }) - /* * * @tc.number SUB_GLOBAL_INTL_JS_NUMBER_2100 * @tc.name format the number with signDisplay @@ -1144,6 +1131,71 @@ describe('intlTest', function () { expect(numfmt.resolvedOptions().unitDisplay).assertEqual('long'); }) + /* * + * @tc.number SUB_GLOBAL_INTL_JS_NUMBER_2250 + * @tc.name format the number with unitUsage + * @tc.desc check the number with unitUsage + */ + it('formatNumber_test_2250', 0, function () { + let numfmt = new Intl.NumberFormat('zh-CN', { style: 'unit', unit: 'meter', + unitDisplay: 'long', unitUsage: 'length-road' }); + console.log('formatNumber_test_2250 ' + numfmt.format(123456.789)); + expect(numfmt.format(123456.789)).assertEqual('123,456.789米'); + expect(numfmt.resolvedOptions().unitUsage).assertEqual('length-road'); + }) + + /* * + * @tc.number SUB_GLOBAL_INTL_JS_NUMBER_2260 + * @tc.name format the number with narrow value in unitUsage param + * @tc.desc check the number with unitUsage + */ + it('formatNumber_test_2260', 0, function () { + let numfmt = new Intl.NumberFormat('zh-CN', { style: 'unit', unit: 'meter', + unitDisplay: 'narrow', unitUsage: 'length-road' }); + console.log('formatNumber_test_2260 ' + numfmt.format(123456.789)); + expect(numfmt.format(123456.789)).assertEqual('123,456.789米'); + expect(numfmt.resolvedOptions().unitUsage).assertEqual('length-road'); + }) + + /* * + * @tc.number SUB_GLOBAL_INTL_JS_NUMBER_2270 + * @tc.name format the number with short value in unitUsage param + * @tc.desc check the number with unitUsage + */ + it('formatNumber_test_2270', 0, function () { + let numfmt = new Intl.NumberFormat('zh-CN', { style: 'unit', unit: 'meter', + unitDisplay: 'short', unitUsage: 'length-road' }); + console.log('formatNumber_test_2270 ' + numfmt.format(123456.789)); + expect(numfmt.format(123456.789)).assertEqual('123,456.789米'); + expect(numfmt.resolvedOptions().unitUsage).assertEqual('length-road'); + }) + + /* * + * @tc.number SUB_GLOBAL_INTL_JS_NUMBER_2280 + * @tc.name format the number with narrow value in unitUsage param + * @tc.desc check the number with unitUsage + */ + it('formatNumber_test_2280', 0, function () { + let numfmt = new Intl.NumberFormat('en-US', { style: 'unit', unit: 'meter', + unitDisplay: 'narrow', unitUsage: 'length-road' }); + console.log('formatNumber_test_2280 ' + numfmt.format(123456.789)); + expect(numfmt.format(123456.789)).assertEqual('76.712mi'); + expect(numfmt.resolvedOptions().unitUsage).assertEqual('length-road'); + }) + + /* * + * @tc.number SUB_GLOBAL_INTL_JS_NUMBER_2290 + * @tc.name format the number with short value in unitUsage param + * @tc.desc check the number with unitUsage + */ + it('formatNumber_test_2290', 0, function () { + let numfmt = new Intl.NumberFormat('en-US', { style: 'unit', unit: 'meter', + unitDisplay: 'short', unitUsage: 'length-road' }); + console.log('formatNumber_test_2290 ' + numfmt.format(123456.789)); + expect(numfmt.format(123456.789)).assertEqual('76.712 mi'); + expect(numfmt.resolvedOptions().unitUsage).assertEqual('length-road'); + }) + /* * * @tc.number SUB_GLOBAL_INTL_JS_NUMBER_2300 * @tc.name format the number with percetn style -- GitLab