diff --git a/pages/API/storage/storage.test.js b/pages/API/storage/storage.test.js
index d50ec89d1c65ac73bf18628eb2dc9f5467b793d9..312e09c792e73d71267f88292830be0271a8f57b 100644
--- a/pages/API/storage/storage.test.js
+++ b/pages/API/storage/storage.test.js
@@ -168,18 +168,18 @@ describe('ExtApi-StorageInfoTest', () => {
await btnGetStorageButtonInfo.tap()
await page.waitFor(600)
expect(await getData('apiGetData')).toEqual(12345789.235689)
-
-
+
+
// 测试 remove
await btnGetStorageInfoSyncButton.tap()
await page.waitFor(600)
storageInfoRet = await getData('apiGetData')
expect(storageInfoRet.keys[0]).toEqual("autotest_key_mock")
-
+
const btnRemoveStorageInfoSyncButton = await page.$('.btn-removeStorageInfoSync')
await btnRemoveStorageInfoSyncButton.tap()
page.waitFor(600)
-
+
await btnGetStorageInfoSyncButton.tap()
await page.waitFor(600)
storageInfoRet = await getData('apiGetData')
@@ -217,7 +217,23 @@ describe('ExtApi-StorageInfoTest', () => {
let objRet = await getData('apiGetData')
expect(objRet.name).toEqual("tom")
-
+ await page.setData({
+ key: "autotest_key_mock",
+ data:JSON.stringify({
+ name: "james",
+ age: 12,
+ from:"american"
+ })
+ })
+ await page.waitFor(600)
+ btnSetStorageButtonInfo = await page.$('.btn-setstorageSync')
+ await btnSetStorageButtonInfo.tap()
+ await page.waitFor(600)
+ btnGetStorageButtonInfo = await page.$('.btn-getstorageSync')
+ await btnGetStorageButtonInfo.tap()
+ await page.waitFor(600)
+ let jsonStr = await getData('apiGetData')
+ expect(jsonStr).toEqual('{"age":12,"from":"american","name":"james"}')
});
diff --git a/pages/API/storage/storage.uvue b/pages/API/storage/storage.uvue
index 330d869a2f9fb4a7427853ef806100209b3cf925..fb41f47890df49e93f4d05c547813345448cb6df 100644
--- a/pages/API/storage/storage.uvue
+++ b/pages/API/storage/storage.uvue
@@ -78,6 +78,16 @@
>
填充浮点型
+
+
+
+
@@ -147,6 +157,14 @@ export default {
console.log(e)
}
},
+ jsonLikeMock(){
+ this.key = 'key_' + Math.random()
+ this.data = JSON.stringify({
+ name: "james",
+ age: 12,
+ from:"american"
+ });
+ },
strMock() {
this.key = 'key_' + Math.random()
this.data = '测试字符串数据,长度为16个字符'
@@ -197,8 +215,8 @@ export default {
uni.getStorage({
key: key,
success: (res) => {
- that.apiGetData = res.data
+ that.apiGetData = res.data
let desc:string = typeof this.apiGetData
if("object" == desc){
desc = desc + ": " + JSON.stringify(this.apiGetData)