Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
108b3f0a
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
108b3f0a
编写于
8月 16, 2024
作者:
Anne_LXM
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test(editor.test.js): 优化测试例
上级
31f85185
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
6 deletion
+35
-6
pages/component/editor/editor.test.js
pages/component/editor/editor.test.js
+16
-1
pages/component/editor/editor.uvue
pages/component/editor/editor.uvue
+19
-5
未找到文件。
pages/component/editor/editor.test.js
浏览文件 @
108b3f0a
...
@@ -16,6 +16,14 @@ describe('editor.uvue', () => {
...
@@ -16,6 +16,14 @@ describe('editor.uvue', () => {
await
page
.
setData
({
autoTest
:
true
})
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
()
=>
{
it
(
'
editor-wrapper
'
,
async
()
=>
{
expect
(
await
editor
.
attribute
(
"
placeholder
"
)).
toBe
(
"
开始输入...
"
)
expect
(
await
editor
.
attribute
(
"
placeholder
"
)).
toBe
(
"
开始输入...
"
)
expect
(
await
editor
.
attribute
(
"
read-only
"
)).
toBe
(
"
false
"
)
expect
(
await
editor
.
attribute
(
"
read-only
"
)).
toBe
(
"
false
"
)
...
@@ -41,8 +49,9 @@ describe('editor.uvue', () => {
...
@@ -41,8 +49,9 @@ describe('editor.uvue', () => {
});
});
it
(
'
editor-screenshot
'
,
async
()
=>
{
it
(
'
editor-screenshot
'
,
async
()
=>
{
expect
(
await
program
.
screenshot
()).
toSaveImageSnapshot
();
await
setBlur
()
await
page
.
waitFor
(
500
);
await
page
.
waitFor
(
500
);
expect
(
await
program
.
screenshot
()).
toSaveImageSnapshot
();
})
})
it
(
'
clear
'
,
async
()
=>
{
it
(
'
clear
'
,
async
()
=>
{
...
@@ -61,7 +70,13 @@ describe('editor.uvue', () => {
...
@@ -61,7 +70,13 @@ describe('editor.uvue', () => {
})
})
it
(
'
insertImage
'
,
async
()
=>
{
it
(
'
insertImage
'
,
async
()
=>
{
await
page
.
waitFor
(
500
)
await
page
.
callMethod
(
'
insertImage
'
,
'
https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png
'
)
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
)
await
page
.
waitFor
(
2000
)
expect
(
await
program
.
screenshot
()).
toSaveImageSnapshot
();
expect
(
await
program
.
screenshot
()).
toSaveImageSnapshot
();
})
})
...
...
pages/component/editor/editor.uvue
浏览文件 @
108b3f0a
...
@@ -75,9 +75,9 @@
...
@@ -75,9 +75,9 @@
show-img-resize @statuschange="onStatusChange" :read-only="readOnly" @ready="onEditorReady">
show-img-resize @statuschange="onStatusChange" :read-only="readOnly" @ready="onEditorReady">
</editor>
</editor>
</view>
</view>
<view>
<view>
<button @tap="getCon">打印文本内容</button>
<button @tap="getCon">打印文本内容</button>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
...
@@ -99,7 +99,9 @@
...
@@ -99,7 +99,9 @@
autoTest:false,
autoTest:false,
undoTest:false,
undoTest:false,
redoTest:false,
redoTest:false,
removeFormatTest:false
removeFormatTest:false,
insertImageTest:false,
blurTest:false
}
}
},
},
onLoad() {
onLoad() {
...
@@ -137,6 +139,17 @@
...
@@ -137,6 +139,17 @@
}
}
})
})
},
},
blur() {
this.editorCtx.blur({
success: (res) => {
console.log('编辑器失焦:', res)
this.blurTest = true
},
fail: (err) => {
console.log(err)
}
})
},
getCon() {
getCon() {
this.editorCtx.getContents({
this.editorCtx.getContents({
success: (res) => {
success: (res) => {
...
@@ -224,8 +237,9 @@
...
@@ -224,8 +237,9 @@
this.editorCtx.insertImage({
this.editorCtx.insertImage({
src:image,
src:image,
alt: '图像',
alt: '图像',
success:
function()
{
success:
()=>
{
console.log('insert image 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录