From d11ff13bbd4dcee05a829a53d0b77596679d6d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BA=9A=E7=90=AA?= Date: Thu, 7 Nov 2024 18:05:18 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E4=BF=9D=E5=AD=98UTS?= =?UTF-8?q?JSONObject=E5=88=B0storage=E5=86=85=E7=9A=84=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/storage/storage.test.js | 10 ++++++++++ pages/API/storage/storage.uvue | 25 +++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/pages/API/storage/storage.test.js b/pages/API/storage/storage.test.js index 94712686..e1265f44 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 ee22a74c..8db8d8e8 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) + } + }) + } }, } -- GitLab