From c0f4ca1e3b755823d48775284e196fcd9f8f3776 Mon Sep 17 00:00:00 2001 From: chengxingzhen Date: Wed, 20 Jul 2022 09:19:11 +0800 Subject: [PATCH] =?UTF-8?q?XTS=E5=A4=B1=E8=B4=A5=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengxingzhen --- .../js/test/ApplicationInfoJsunit.test.js | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/ability/ability_runtime/fa/faapplicationinfo/entry/src/main/js/test/ApplicationInfoJsunit.test.js b/ability/ability_runtime/fa/faapplicationinfo/entry/src/main/js/test/ApplicationInfoJsunit.test.js index c9b0173ad..e51fe2fda 100644 --- a/ability/ability_runtime/fa/faapplicationinfo/entry/src/main/js/test/ApplicationInfoJsunit.test.js +++ b/ability/ability_runtime/fa/faapplicationinfo/entry/src/main/js/test/ApplicationInfoJsunit.test.js @@ -27,7 +27,7 @@ var getCallingBundleType = { } describe('ApplicationInfoTest', function () { - var TAG = '';- + var TAG = ''; /* * @tc.number SUB_AA_OpenHarmony_FormBase_1000 @@ -44,11 +44,26 @@ describe('ApplicationInfoTest', function () { "test":11, "test3":true } - var result = formBindingData.createFormBindingData(dataObj) - console.log(TAG + " result is : " + JSON.stringify(result)) - expect(JSON.stringify(result)). - assertEqual(JSON.stringify({"data":"{\"temperature\":\"11c\",\"time\":\"11:00\",\"test\":11,\"test3\":true}"})); - done(); + var formData = formBindingData.createFormBindingData(dataObj) + console.info(TAG + " result is : " + JSON.stringify(formData)) + + let formDataStr = JSON.stringify(formData.data); + let formDataStrToObj = JSON.parse(formDataStr); + if (typeof(formDataStrToObj) == "string" ) { + console.info(TAG + " formDataStrToObj1 is : " + typeof formDataStrToObj) + let formDataStrToObj2 = JSON.parse(formDataStrToObj) + console.info(TAG + " formDataStrToObj2 is : " + typeof formDataStrToObj2) + expect(formDataStrToObj2.test).assertEqual(11) + expect(formDataStrToObj2.test3).assertTrue() + expect(formDataStrToObj2.time).assertEqual("11:00") + done(); + } else { + console.info(TAG + " formDataStrToObj is : " + typeof formDataStrToObj) + expect(formDataStrToObj.test).assertEqual(11) + expect(formDataStrToObj.test3).assertTrue() + expect(formDataStrToObj.time).assertEqual("11:00") + done(); + } console.info('------------end SUB_AA_OpenHarmony_FormBase_1000-------------'); }); -- GitLab