提交 d11ff13b 编写于 作者: 雪洛's avatar 雪洛

test: 增加保存UTSJSONObject到storage内的测试例

上级 42f044c2
...@@ -300,4 +300,14 @@ describe('ExtApi-StorageInfoTest', () => { ...@@ -300,4 +300,14 @@ describe('ExtApi-StorageInfoTest', () => {
}); });
it('saveUTSJSONObject', async () => {
await page.callMethod('jest_saveUTSJSONObject')
const {
jest_saveUTSJSONObjectSyncResult,
jest_saveUTSJSONObjectAsyncResult
} = await page.data()
expect(jest_saveUTSJSONObjectSyncResult).toBe(true)
expect(jest_saveUTSJSONObjectAsyncResult).toBe(true)
})
}); });
...@@ -112,7 +112,9 @@ ...@@ -112,7 +112,9 @@
data: '' as any, data: '' as any,
apiGetData: '' as any | null, apiGetData: '' as any | null,
storageInfo: '', storageInfo: '',
staticComplexRet: false staticComplexRet: false,
jest_saveUTSJSONObjectSyncResult: false,
jest_saveUTSJSONObjectAsyncResult: false
} }
}, },
methods: { methods: {
...@@ -369,6 +371,25 @@ ...@@ -369,6 +371,25 @@
showCancel: false, showCancel: false,
}) })
}, },
jest_saveUTSJSONObject: function () {
const key = 'test_key_saveUTSJSONObject'
uni.setStorageSync(key, {
a: {
b: 1
}
})
const dataSync = uni.getStorageSync(key)
this.jest_saveUTSJSONObjectSyncResult = dataSync instanceof UTSJSONObject && dataSync['a'] instanceof UTSJSONObject
uni.getStorage({
key,
success: (res) => {
const data = res.data
this.jest_saveUTSJSONObjectAsyncResult = data instanceof UTSJSONObject && data['a'] instanceof UTSJSONObject
console.log('this.jest_saveUTSJSONObjectSyncResult: ' + this.jest_saveUTSJSONObjectSyncResult)
console.log('this.jest_saveUTSJSONObjectAsyncResult: ' + this.jest_saveUTSJSONObjectAsyncResult)
}
})
}
}, },
} }
</script> </script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册