From 10d50717d5791d5f396a63a75ac28d62c293e53a Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Mon, 9 Dec 2024 23:41:17 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0getStorage=E8=8E=B7?= =?UTF-8?q?=E5=8F=96UTSJSONObject=E6=95=B0=E7=BB=84=E7=9A=84=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/storage/storage.test.js | 9 +++++++++ pages/API/storage/storage.uvue | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pages/API/storage/storage.test.js b/pages/API/storage/storage.test.js index e3371619..c6b0d47a 100644 --- a/pages/API/storage/storage.test.js +++ b/pages/API/storage/storage.test.js @@ -311,4 +311,13 @@ describe('ExtApi-StorageInfoTest', () => { expect(jest_saveUTSJSONObjectAsyncResult).toBe(1) }) + it('saveUTSJSONObjectArray', async () => { + await page.callMethod('jest_saveUTSJSONObjectArray') + await page.waitFor(600) + const { + jest_saveUTSJSONObjectArraySyncResult + } = await page.data() + expect(jest_saveUTSJSONObjectArraySyncResult).toBe(1) + }) + }); diff --git a/pages/API/storage/storage.uvue b/pages/API/storage/storage.uvue index 335e1f2d..6aa4cb2d 100644 --- a/pages/API/storage/storage.uvue +++ b/pages/API/storage/storage.uvue @@ -114,7 +114,8 @@ storageInfo: '', staticComplexRet: false, jest_saveUTSJSONObjectSyncResult: 0, - jest_saveUTSJSONObjectAsyncResult: 0 + jest_saveUTSJSONObjectAsyncResult: 0, + jest_saveUTSJSONObjectArraySyncResult: 0 } }, methods: { @@ -391,6 +392,14 @@ console.log('this.jest_saveUTSJSONObjectAsyncResult: ' + this.jest_saveUTSJSONObjectAsyncResult) } }) + }, + jest_saveUTSJSONObjectArray() { + const key = 'test_key_saveUTSJSONObjectArray' + uni.setStorageSync(key, [{ + a: 1 + }] as UTSJSONObject[]) + const dataSync = uni.getStorageSync(key) as UTSJSONObject[] + this.jest_saveUTSJSONObjectArraySyncResult = dataSync[0].get('a') as number } }, } -- GitLab