提交 a8d7362d 编写于 作者: Anne_LXM's avatar Anne_LXM

test(editor.test.js): 优化测试例

上级 cbfcde03
......@@ -16,6 +16,14 @@ describe('editor.uvue', () => {
await page.setData({autoTest:true})
});
async function setBlur() {
const start = Date.now();
await page.callMethod('blur')
await page.waitFor(async () => {
return await page.data('blurTest') === true || (Date.now() - start > 2000)
})
}
it('editor-wrapper', async () => {
expect(await editor.attribute("placeholder")).toBe("开始输入...")
expect(await editor.attribute("read-only")).toBe("false")
......@@ -41,8 +49,9 @@ describe('editor.uvue', () => {
});
it('editor-screenshot', async () => {
expect(await program.screenshot()).toSaveImageSnapshot();
await setBlur()
await page.waitFor(500);
expect(await program.screenshot()).toSaveImageSnapshot();
})
it('clear', async () => {
......@@ -61,7 +70,13 @@ describe('editor.uvue', () => {
})
it('insertImage', async () => {
await page.waitFor(500)
await page.callMethod('insertImage','https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png')
const start1 = Date.now();
await page.waitFor(async () => {
return await page.data('insertImageTest') === true || (Date.now() - start1 > 2000)
})
await setBlur()
await page.waitFor(2000)
expect(await program.screenshot()).toSaveImageSnapshot();
})
......
......@@ -99,7 +99,9 @@
autoTest:false,
undoTest:false,
redoTest:false,
removeFormatTest:false
removeFormatTest:false,
insertImageTest:false,
blurTest:false
}
},
onLoad() {
......@@ -137,6 +139,17 @@
}
})
},
blur() {
this.editorCtx.blur({
success: (res) => {
console.log('编辑器失焦:', res)
this.blurTest = true
},
fail: (err) => {
console.log(err)
}
})
},
getCon() {
this.editorCtx.getContents({
success: (res) => {
......@@ -224,8 +237,9 @@
this.editorCtx.insertImage({
src:image,
alt: '图像',
success: function() {
success: ()=> {
console.log('insert image success')
this.insertImageTest = true
}
})
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册