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

fix: 修复保存UTSJSONObject到storage内的测试例在安卓端测试失败的Bug

上级 b7dd27a1
...@@ -306,8 +306,8 @@ describe('ExtApi-StorageInfoTest', () => { ...@@ -306,8 +306,8 @@ describe('ExtApi-StorageInfoTest', () => {
jest_saveUTSJSONObjectSyncResult, jest_saveUTSJSONObjectSyncResult,
jest_saveUTSJSONObjectAsyncResult jest_saveUTSJSONObjectAsyncResult
} = await page.data() } = await page.data()
expect(jest_saveUTSJSONObjectSyncResult).toBe(true) expect(jest_saveUTSJSONObjectSyncResult).toBe(1)
expect(jest_saveUTSJSONObjectAsyncResult).toBe(true) expect(jest_saveUTSJSONObjectAsyncResult).toBe(1)
}) })
}); });
...@@ -113,8 +113,8 @@ ...@@ -113,8 +113,8 @@
apiGetData: '' as any | null, apiGetData: '' as any | null,
storageInfo: '', storageInfo: '',
staticComplexRet: false, staticComplexRet: false,
jest_saveUTSJSONObjectSyncResult: false, jest_saveUTSJSONObjectSyncResult: 0,
jest_saveUTSJSONObjectAsyncResult: false jest_saveUTSJSONObjectAsyncResult: 0
} }
}, },
methods: { methods: {
...@@ -378,13 +378,15 @@ ...@@ -378,13 +378,15 @@
b: 1 b: 1
} }
}) })
const dataSync = uni.getStorageSync(key) const dataSync = uni.getStorageSync(key) as UTSJSONObject
this.jest_saveUTSJSONObjectSyncResult = dataSync instanceof UTSJSONObject && dataSync['a'] instanceof UTSJSONObject const dataSyncA = dataSync['a'] as UTSJSONObject
this.jest_saveUTSJSONObjectSyncResult = dataSyncA.get('b') as number
uni.getStorage({ uni.getStorage({
key, key,
success: (res) => { success: (res) => {
const data = res.data const dataAsync = res.data as UTSJSONObject
this.jest_saveUTSJSONObjectAsyncResult = data instanceof UTSJSONObject && data['a'] instanceof UTSJSONObject const dataAsyncA = dataAsync['a'] as UTSJSONObject
this.jest_saveUTSJSONObjectAsyncResult = dataAsyncA.get('b') as number
console.log('this.jest_saveUTSJSONObjectSyncResult: ' + this.jest_saveUTSJSONObjectSyncResult) console.log('this.jest_saveUTSJSONObjectSyncResult: ' + this.jest_saveUTSJSONObjectSyncResult)
console.log('this.jest_saveUTSJSONObjectAsyncResult: ' + this.jest_saveUTSJSONObjectAsyncResult) console.log('this.jest_saveUTSJSONObjectAsyncResult: ' + this.jest_saveUTSJSONObjectAsyncResult)
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册