提交 f9c4b900 编写于 作者: 杜庆泉's avatar 杜庆泉

storage 增加 类json格式字符串测试示例

上级 7f6591dc
......@@ -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"}')
});
......
......@@ -78,6 +78,16 @@
>
填充浮点型
</button>
</view>
<view class="uni-flex uni-row">
<button
type="default"
style="width:750rpx"
@tap="jsonLikeMock"
>
填充符合json格式的字符串
</button>
</view>
</view>
<view class="uni-padding-wrap">
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册