diff --git a/pages/API/storage/storage.test.js b/pages/API/storage/storage.test.js index 947126863a751e1b318da8d013a83787597ff458..e1265f44fe33dd0a8f3f612018354a03594231a7 100644 --- a/pages/API/storage/storage.test.js +++ b/pages/API/storage/storage.test.js @@ -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) + }) + }); diff --git a/pages/API/storage/storage.uvue b/pages/API/storage/storage.uvue index ee22a74ccc448a7c8f934163092b0063f8c960d0..8db8d8e8d8b4085082e785bc312154b4efccee23 100644 --- a/pages/API/storage/storage.uvue +++ b/pages/API/storage/storage.uvue @@ -112,7 +112,9 @@ data: '' as any, apiGetData: '' as any | null, storageInfo: '', - staticComplexRet: false + staticComplexRet: false, + jest_saveUTSJSONObjectSyncResult: false, + jest_saveUTSJSONObjectAsyncResult: false } }, methods: { @@ -368,7 +370,26 @@ content: ' ', 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) + } + }) + } }, }