diff --git a/pages/component/editor/editor.test.js b/pages/component/editor/editor.test.js index cef1f326c1301a59b341a7e72fb5ede97c0fe7c7..ae7dc71815f7abcc98c195d8b3602613ccd9e824 100644 --- a/pages/component/editor/editor.test.js +++ b/pages/component/editor/editor.test.js @@ -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(); }) diff --git a/pages/component/editor/editor.uvue b/pages/component/editor/editor.uvue index 88edd341480d0e1dc8851aebd0e1c47bb7ac2b5a..c0524a47c81a211568958b330635c7dbe0f38d64 100644 --- a/pages/component/editor/editor.uvue +++ b/pages/component/editor/editor.uvue @@ -75,9 +75,9 @@ show-img-resize @statuschange="onStatusChange" :read-only="readOnly" @ready="onEditorReady"> - - - + + + @@ -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 } }) },