Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
京东前端
nutui-react
提交
9c089d5b
N
nutui-react
项目概览
京东前端
/
nutui-react
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nutui-react
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9c089d5b
编写于
8月 15, 2022
作者:
S
shadow-Fiend
提交者:
GitHub
8月 15, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: timeselect (#216)
上级
acb3dba0
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
173 addition
and
3 deletion
+173
-3
src/packages/timeselect/__test__/__snapshots__/timeselect.spec.tsx.snap
...imeselect/__test__/__snapshots__/timeselect.spec.tsx.snap
+69
-0
src/packages/timeselect/__test__/timeselect.spec.tsx
src/packages/timeselect/__test__/timeselect.spec.tsx
+97
-0
src/packages/timeselect/demo.tsx
src/packages/timeselect/demo.tsx
+7
-3
未找到文件。
src/packages/timeselect/__test__/__snapshots__/timeselect.spec.tsx.snap
0 → 100644
浏览文件 @
9c089d5b
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`timeselect props test 1`] = `
<div>
<div
class="overlay-fade-enter-active nut-overlay"
style="z-index: 2000; animation-duration: 0.3s;"
/>
<div
class="round popup-bottom undefined nut-popup"
style="width: 100%; height: 50%; z-index: 2000; animation-duration: 0.3s;"
>
<div
class="nut-timeselect "
>
<div
class="nut-timeselect__title"
>
取件时间 1
</div>
<div
class="nut-timeselect__content"
>
<div
class="nut-timeselect__content-left"
>
<div
class="nut-timepannel nut-timepannel-active"
>
5月20日(今天)
</div>
<div
class="nut-timepannel "
>
5月21日(星期三)
</div>
</div>
<div
class="nut-timedetail "
>
<span
class="nut-timedetail__item"
>
9:00-10:00
</span>
<span
class="nut-timedetail__item"
>
10:00-11:00
</span>
<span
class="nut-timedetail__item"
>
11:00-12:00
</span>
</div>
</div>
</div>
<div
class="nutui-popup__close-icon nutui-popup__close-icon--top-right"
>
<i
class=" nutui-iconfont nut-icon nutui-icon nut-icon-close "
style="font-size: 12px; width: 12px; height: 12px;"
/>
</div>
</div>
</div>
`;
src/packages/timeselect/__test__/timeselect.spec.tsx
0 → 100644
浏览文件 @
9c089d5b
import
*
as
React
from
'
react
'
import
{
render
,
waitFor
}
from
'
@testing-library/react
'
import
'
@testing-library/jest-dom
'
import
ReactTestUtils
from
'
react-dom/test-utils
'
import
{
TimeSelect
}
from
'
../timeselect
'
const
state
=
{
visible1
:
true
,
height
:
'
50%
'
,
title
:
'
取件时间 1
'
,
currentKey
:
0
,
dates
:
[
{
'
pannel-key
'
:
'
0
'
,
date
:
'
5月20日(今天)
'
,
},
{
'
pannel-key
'
:
'
1
'
,
date
:
'
5月21日(星期三)
'
,
},
],
times
:
[
{
key
:
'
0
'
,
list
:
[
'
9:00-10:00
'
,
'
10:00-11:00
'
,
'
11:00-12:00
'
],
},
{
key
:
'
1
'
,
list
:
[
'
9:00-10:00
'
,
'
10:00-11:00
'
],
},
],
}
test
(
'
timeselect props test
'
,
async
()
=>
{
const
App
=
()
=>
{
return
(
<
TimeSelect
visible
=
{
state
.
visible1
}
height
=
{
state
.
height
}
title
=
{
state
.
title
}
multiple
currentKey
=
{
state
.
currentKey
}
dates
=
{
state
.
dates
}
times
=
{
state
.
times
}
/>
)
}
const
{
container
}
=
render
(<
App
/>)
await
waitFor
(
()
=>
{
const
titleDoms
=
container
.
querySelectorAll
(
'
.nut-timeselect__title
'
)
expect
(
titleDoms
[
0
].
innerHTML
).
toBe
(
state
.
title
)
container
.
querySelectorAll
(
'
.nut-timepannel
'
).
forEach
((
item
,
index
)
=>
{
expect
(
item
.
innerHTML
).
toBe
(
state
.
dates
[
index
].
date
)
})
},
{
timeout
:
2000
}
)
await
waitFor
(
()
=>
{
expect
(
container
.
querySelector
(
'
.nut-timedetail
'
)).
toBeInTheDocument
()
expect
(
container
).
toMatchSnapshot
()
},
{
timeout
:
2000
}
)
})
test
(
'
timeselect event test
'
,
async
()
=>
{
const
App
=
()
=>
{
return
(
<
TimeSelect
visible
=
{
state
.
visible1
}
height
=
{
state
.
height
}
title
=
{
state
.
title
}
multiple
currentKey
=
{
state
.
currentKey
}
dates
=
{
state
.
dates
}
times
=
{
state
.
times
}
/>
)
}
const
{
container
}
=
render
(<
App
/>)
await
waitFor
(
()
=>
{
container
.
querySelectorAll
(
'
.nut-timedetail__item
'
)
.
forEach
((
item
,
index
)
=>
{
ReactTestUtils
.
Simulate
.
click
(
item
)
expect
(
item
).
toHaveClass
(
'
nut-timedetail__item-active
'
)
})
},
{
timeout
:
2000
}
)
})
src/packages/timeselect/demo.tsx
浏览文件 @
9c089d5b
import
React
,
{
useState
}
from
'
react
'
import
{
TimeSelect
}
from
'
./timeselect
'
import
{
TimeType
}
from
'
../timedetail/timedetail
'
import
{
Cell
}
from
'
../cell/cell
'
import
Toast
from
'
../toast
'
import
{
useTranslate
}
from
'
../../sites/assets/locale
'
...
...
@@ -57,16 +58,19 @@ const TimeSelectDemo = () => {
SetVisible1
(
true
)
}
// 点击弹层 X 或者弹层外区域触发事件
const
handleSelect
=
(
selectTimeData
:
any
)
=>
{
const
handleSelect
=
(
selectTimeData
:
TimeType
[]
)
=>
{
SetVisible1
(
false
)
Toast
.
text
(
`
${
translated
.
text1
}
:
${
JSON
.
stringify
(
selectTimeData
)}
`
)
}
// 选择日期触发回调事件
const
handlePannelChange
=
(
pannelKey
:
any
,
selectTimeData
:
any
)
=>
{
const
handlePannelChange
=
(
pannelKey
:
string
|
number
,
selectTimeData
:
TimeType
[]
)
=>
{
console
.
log
(
'
pannelKey, selectTimeData:
'
,
pannelKey
,
selectTimeData
)
}
// 选择配送时间触发回调事件
const
handleTimeChange
=
(
time
:
any
,
selectTimeData
:
any
)
=>
{
const
handleTimeChange
=
(
time
:
string
,
selectTimeData
:
TimeType
[]
)
=>
{
console
.
log
(
'
time, selectTimeData:
'
,
time
,
selectTimeData
)
}
return
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录