diff --git a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts index 92f4468df6b923d956394f2ec76b7e959c6a48ed..f5fa83deb0c445adc3d32c8305b888a5780823ba 100644 --- a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts +++ b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts @@ -12,7 +12,32 @@ export function testUTSJSONObject() : Result { expect(UTSJSONObject.keys(obj).length).toEqual(2); console.log(UTSJSONObject.keys(obj)) }) - + test('toJSONObject', () => { + // #ifdef APP-ANDROID + let result = {} + result["opt"] = "xxxx" + + let subArray = [] as Array + let subModel = {} + subModel["name"] = "xxx" + subModel["type"] = 0 + subArray.push(subModel) + + let service = {} + service["name"] = "0xxxb34fb" + service["type"] = 0 + + //这个数据返回为空对象数组 + service["array"] = subArray + + result["service"] = service + + expect(result.toJSONObject().toJSONString()).toEqual('{"opt":"xxxx","service":{"array":[{"name":"xxx","type":0}],"name":"0xxxb34fb","type":0}}'); + + // #endif + }) + + test('assign-notype', () => { // #ifdef APP-ANDROID const target = { a: 1, b: 2 };