diff --git a/pages/API/storage/storage.test.js b/pages/API/storage/storage.test.js index e1265f44fe33dd0a8f3f612018354a03594231a7..bb1efb3535b0f2d6f255d8aa77cf9118f1ae86bb 100644 --- a/pages/API/storage/storage.test.js +++ b/pages/API/storage/storage.test.js @@ -306,8 +306,8 @@ describe('ExtApi-StorageInfoTest', () => { jest_saveUTSJSONObjectSyncResult, jest_saveUTSJSONObjectAsyncResult } = await page.data() - expect(jest_saveUTSJSONObjectSyncResult).toBe(true) - expect(jest_saveUTSJSONObjectAsyncResult).toBe(true) + expect(jest_saveUTSJSONObjectSyncResult).toBe(1) + expect(jest_saveUTSJSONObjectAsyncResult).toBe(1) }) }); diff --git a/pages/API/storage/storage.uvue b/pages/API/storage/storage.uvue index 8db8d8e8d8b4085082e785bc312154b4efccee23..335e1f2d20cd5fb3a7192085d55dda2ea9cf995a 100644 --- a/pages/API/storage/storage.uvue +++ b/pages/API/storage/storage.uvue @@ -113,8 +113,8 @@ apiGetData: '' as any | null, storageInfo: '', staticComplexRet: false, - jest_saveUTSJSONObjectSyncResult: false, - jest_saveUTSJSONObjectAsyncResult: false + jest_saveUTSJSONObjectSyncResult: 0, + jest_saveUTSJSONObjectAsyncResult: 0 } }, methods: { @@ -378,13 +378,15 @@ b: 1 } }) - const dataSync = uni.getStorageSync(key) - this.jest_saveUTSJSONObjectSyncResult = dataSync instanceof UTSJSONObject && dataSync['a'] instanceof UTSJSONObject + const dataSync = uni.getStorageSync(key) as UTSJSONObject + const dataSyncA = dataSync['a'] as UTSJSONObject + this.jest_saveUTSJSONObjectSyncResult = dataSyncA.get('b') as number uni.getStorage({ key, success: (res) => { - const data = res.data - this.jest_saveUTSJSONObjectAsyncResult = data instanceof UTSJSONObject && data['a'] instanceof UTSJSONObject + const dataAsync = res.data as 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_saveUTSJSONObjectAsyncResult: ' + this.jest_saveUTSJSONObjectAsyncResult) }