提交 b2e6af9a 编写于 作者: shutao-dc's avatar shutao-dc

update image.test.js

上级 9373ac23
...@@ -11,4 +11,22 @@ describe('component-native-image', () => { ...@@ -11,4 +11,22 @@ describe('component-native-image', () => {
it('check_image_load', async () => { it('check_image_load', async () => {
expect(await page.data('loadError')).toBe(false) expect(await page.data('loadError')).toBe(false)
}); });
it('check_image_load_url', async () => {
await page.setData({
loadError: false,
imageSrc: 'https://request.dcloud.net.cn/api/http/contentType/image/png'
})
await page.waitFor(300);
expect(await page.data('loadError')).toBe(false)
})
it('check_image_load_error', async () => {
await page.setData({
loadError: false,
imageSrc: 'testerror.jpg'
})
await page.waitFor(300);
expect(await page.data('loadError')).toBe(true)
})
}); });
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view class="uni-center" style="background:#FFFFFF;"> <view class="uni-center" style="background:#FFFFFF;">
<image class="image" :fade-show="true" mode="widthFix" src="/static/test-image/logo.png" @error="error" <image class="image" :fade-show="true" mode="widthFix" :src="imageSrc" @error="error"
@load="load"></image> @load="load"></image>
</view> </view>
<view class="uni-btn-v"> <view class="uni-btn-v">
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
data() { data() {
return { return {
title: 'image', title: 'image',
imageSrc: "/static/test-image/logo.png",
loadError: false loadError: false
} }
}, },
......
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('test title', () => {
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/component/web-view-local/web-view-local');
await page.waitFor(1000);
});
it('check_load_url', async () => {
expect(await page.data('loadError')).toBe(false)
});
});
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
export default { export default {
data() { data() {
return { return {
loadError: false
} }
}, },
methods: { methods: {
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
}); });
}, },
error(event : WebViewErrorEvent) { error(event : WebViewErrorEvent) {
this.loadError = true
console.log(JSON.stringify(event.detail)); console.log(JSON.stringify(event.detail));
}, },
loading(event : WebViewLoadingEvent) { loading(event : WebViewLoadingEvent) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册