diff --git a/pages/API/show-toast/show-toast.test.js b/pages/API/show-toast/show-toast.test.js
index 4f86d4fa1c6eb910857c5e3242b7a7e8b0a557c4..43dada2824d8166e30363460e7f5b6fd197da68e 100644
--- a/pages/API/show-toast/show-toast.test.js
+++ b/pages/API/show-toast/show-toast.test.js
@@ -1,27 +1,19 @@
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('API-toast', () => {
-
let page;
const isApp = process.env.UNI_OS_NAME === "android" || process.env.UNI_OS_NAME === "ios";
-
-
beforeAll(async () => {
page = await program.reLaunch('/pages/API/show-toast/show-toast')
- await page.waitFor(600);
+ await page.waitFor("view");
});
-
-
- it("onload-toast-test", async () => {
-
-
+ async function toScreenshot(imgName) {
if (isApp) {
await page.waitFor(500);
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
-
const image = await program.screenshot({
deviceShot: true,
area: {
@@ -31,163 +23,53 @@ describe('API-toast', () => {
width:windowWidth
},
});
- expect(image).toSaveImageSnapshot();
+ expect(image).toSaveImageSnapshot({customSnapshotIdentifier() {
+ return imgName
+ }})
}else{
const image = await program.screenshot({
deviceShot: true,
fullPage: true
});
- expect(image).toSaveImageSnapshot()
+ expect(image).toSaveImageSnapshot({customSnapshotIdentifier() {
+ return imgName
+ }})
}
- })
+ await page.waitFor(500);
+ }
-
-
- it("btn-toast-default-1", async () => {
- const btnToastDefaultButton = await page.$('#btn-toast-default')
- await btnToastDefaultButton.tap()
- await page.waitFor(200)
- if (isApp) {
-
- const res = await page.callMethod('jest_getWindowInfo')
- const windowHeight = res.windowHeight * res.pixelRatio;
- const windowWidth = res.windowWidth * res.pixelRatio;
-
- const image = await program.screenshot({
- deviceShot: true,
- area: {
- x: 0,
- y: 200,
- height: windowHeight - 200,
- width:windowWidth
- },
- });
- expect(image).toSaveImageSnapshot();
- }else{
- const image = await program.screenshot({
- deviceShot: true,
- fullPage: true
- });
- expect(image).toSaveImageSnapshot()
- }
+ it("onload-toast-test", async () => {
+ await toScreenshot('toast-onload')
})
-
-
- it("btn-toast-duration-1", async () => {
- const btnToastDurationButton = await page.$('#btn-toast-duration')
- await btnToastDurationButton.tap()
- await page.waitFor(2000)
- if (isApp) {
- const res = await page.callMethod('jest_getWindowInfo')
- const windowHeight = res.windowHeight * res.pixelRatio;
- const windowWidth = res.windowWidth * res.pixelRatio;
- const image = await program.screenshot({
- deviceShot: true,
- area: {
- x: 0,
- y: 200,
- height: windowHeight - 200,
- width:windowWidth
- },
- });
- expect(image).toSaveImageSnapshot();
- }else{
- const image = await program.screenshot({
- deviceShot: true,
- fullPage: true
- });
- expect(image).toSaveImageSnapshot()
+ it("icon-toast-test", async () => {
+ const icons = await page.$$('.radio-icon')
+ for (let i = 0; i < icons.length; i++) {
+ await icons[i].tap()
+ const iconText = await icons[i].text()
+ await page.callMethod('toast1Tap')
+ await page.waitFor(100);
+ await toScreenshot(`${iconText}`)
}
})
- it("btn-toast-errorIcon-1", async () => {
- const btnToastErrorIconButton = await page.$('#btn-toast-errorIcon')
- await btnToastErrorIconButton.tap()
- await page.waitFor(200)
- if (isApp) {
- const res = await page.callMethod('jest_getWindowInfo')
- const windowHeight = res.windowHeight * res.pixelRatio;
- const windowWidth = res.windowWidth * res.pixelRatio;
- const image = await program.screenshot({
- deviceShot: true,
- area: {
- x: 0,
- y: 200,
- height: windowHeight - 200,
- width:windowWidth
- },
- });
- expect(image).toSaveImageSnapshot();
- }else{
- const image = await program.screenshot({
- deviceShot: true,
- fullPage: true
- });
- expect(image).toSaveImageSnapshot()
- }
+ it("image-toast-test", async () => {
+ await page.setData({imageSelect: true})
+ await page.waitFor(300);
+ await page.callMethod('toast1Tap')
+ await page.waitFor(300);
+ await toScreenshot('toast-image')
})
-
- it("btn-toast-loading-1", async () => {
- const btnToastLoadingButton = await page.$('#btn-toast-loading')
- await btnToastLoadingButton.tap()
- await page.waitFor(200)
-
- const btnToastHideButton = await page.$('#btn-toast-hide')
- await btnToastHideButton.tap()
- await page.waitFor(1000)
-
- if (isApp) {
- const res = await page.callMethod('jest_getWindowInfo')
- const windowHeight = res.windowHeight * res.pixelRatio;
- const windowWidth = res.windowWidth * res.pixelRatio;
- const image = await program.screenshot({
- deviceShot: true,
- area: {
- x: 0,
- y: 200,
- height: windowHeight - 200,
- width:windowWidth
- },
- });
- expect(image).toSaveImageSnapshot();
- }else{
- const image = await program.screenshot({
- deviceShot: true,
- fullPage: true
- });
- expect(image).toSaveImageSnapshot()
- }
+ it("duration-toast-test", async () => {
+ await page.setData({intervalSelect: 4000})
+ await page.callMethod('toast1Tap')
+ await page.waitFor(2000);
+ await toScreenshot('toast-duration-2000')
+ await page.waitFor(1000);
+ await page.callMethod('hideToast')
+ await page.waitFor(300);
+ await toScreenshot('toast-duration-end')
})
-
- // it("btn-toast-postion-bottom-1", async () => {
- // const btnToastButton = await page.$('#btn-toast-postion-bottom')
- // await btnToastButton.tap()
- // await page.waitFor(200)
- // if (isApp) {
- // const windowHeight = uni.getWindowInfo().windowHeight;
- // const windowWidth = uni.getWindowInfo().windowWidth;
- // const image = await program.screenshot({
- // deviceShot: true,
- // area: {
- // x: 0,
- // y: 200,
- // height: windowHeight,
- // width:windowWidth
- // },
- // });
- // expect(image).toSaveImageSnapshot();
- // }else{
- // const image = await program.screenshot({
- // deviceShot: true,
- // fullPage: true
- // });
- // expect(image).toSaveImageSnapshot()
- // }
- // })
-
-
-
});
diff --git a/pages/API/show-toast/show-toast.uvue b/pages/API/show-toast/show-toast.uvue
index 3aa2c5b6c9a3d877f238c7014cb1ab2fd2f6ec93..b8dc765e0c5c2d8207272e71140b5a5d84d13704 100644
--- a/pages/API/show-toast/show-toast.uvue
+++ b/pages/API/show-toast/show-toast.uvue
@@ -1,31 +1,105 @@
-
+
+
+
+
+ 设置icon
+
+
+
+ {{icon.name}}
+
+
+
+ 是否显示自定义图标
+
+
+
+ 是否显示透明蒙层-屏蔽点击事件
+
+
+ 提示的延迟时间,默认:1500(单位毫秒)
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 设置position,仅App生效
+
+
+
+ {{position.name}}
+
+
+
+
{{exeRet}}
-
+
+
+
-
+