Skip to content

Commit

Permalink
docs: update 3.x version
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode committed Aug 29, 2023
1 parent ad2dd22 commit 4d1f893
Show file tree
Hide file tree
Showing 16 changed files with 2,198 additions and 292 deletions.
4 changes: 0 additions & 4 deletions i18n/en/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,5 @@
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": {
"message": "Toggle navigation bar",
"description": "The ARIA label for hamburger menu button of mobile navigation"
},
"讨论区": {
"message": "Discussion Area",
"description": "The footer content"
}
}
4 changes: 4 additions & 0 deletions i18n/en/docusaurus-plugin-content-docs/current.json
Original file line number Diff line number Diff line change
Expand Up @@ -590,5 +590,9 @@
"sidebar.API.category.人脸检测": {
"message": "Face recognition",
"description": "The label for category 人脸检测 in sidebar API"
},
"sidebar.docs.category.测试工具": {
"message": "Test units",
"description": "The label for category 测试工具 in sidebar docs"
}
}
4 changes: 4 additions & 0 deletions i18n/en/docusaurus-plugin-content-docs/version-3.x.json
Original file line number Diff line number Diff line change
Expand Up @@ -590,5 +590,9 @@
"sidebar.API.category.人脸检测": {
"message": "Face recognition",
"description": "The label for category 人脸检测 in sidebar API"
},
"sidebar.docs.category.测试工具": {
"message": "Test units",
"description": "The label for category 测试工具 in sidebar docs"
}
}
12 changes: 6 additions & 6 deletions versioned_docs/version-3.x/apis/network/request/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ sidebar_label: request
| mode | `keyof CorsMode` | `"same-origin"` | 否 | 设置是否允许跨域请求<br />API 支持度: h5 |
| credentials | `keyof Credentials` | `"omit"` | 否 | 设置是否携带 Cookie<br />API 支持度: h5 |
| cache | `keyof Cache` | `"default"` | 否 | 设置缓存模式<br />API 支持度: h5 |
| retryTimes | `number` | `2` | 否 | 设置请求重试次数<br />API 支持度: h5 |
| backup | string or string[] | | 否 | 设置请求的兜底接口<br />API 支持度: h5 |
| retryTimes | `number` | `2` | 否 | 设置请求重试次数<br />API 支持度: h5<br />h5: 仅在 jsonp 模式下生效 |
| backup | string or string[] | | 否 | 设置请求的兜底接口<br />API 支持度: h5<br />h5: 仅在 jsonp 模式下生效 |
| signal | `AbortSignal` | | 否 | 设置请求中止信号<br />API 支持度: h5 |
| dataCheck | `() => boolean` | | 否 | 设置请求响应的数据校验函数,若返回 false,则请求兜底接口,若无兜底接口,则报请求失败<br />API 支持度: h5 |
| useStore | `boolean` | `false` | 否 | 设置请求是否使用缓存<br />API 支持度: h5 |
| storeCheckKey | `string` | | 否 | 设置请求缓存校验的 key<br />API 支持度: h5 |
| storeSign | `string` | | 否 | 设置请求缓存签名<br />API 支持度: h5 |
| dataCheck | `() => boolean` | | 否 | 设置请求响应的数据校验函数,若返回 false,则请求兜底接口,若无兜底接口,则报请求失败<br />API 支持度: h5<br />h5: 仅在 jsonp 模式下生效 |
| useStore | `boolean` | `false` | 否 | 设置请求是否使用缓存<br />API 支持度: h5<br />h5: 仅在 jsonp 模式下生效 |
| storeCheckKey | `string` | | 否 | 设置请求缓存校验的 key<br />API 支持度: h5<br />h5: 仅在 jsonp 模式下生效 |
| storeSign | `string` | | 否 | 设置请求缓存签名<br />API 支持度: h5<br />h5: 仅在 jsonp 模式下生效 |
| storeCheck | `() => boolean` | | 否 | 设置请求校验函数,一般不需要设置<br />API 支持度: h5 |

### SuccessCallbackResult
Expand Down
5 changes: 5 additions & 0 deletions versioned_docs/version-3.x/components/forms/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export default {
| shareMessageFriendInfo | `string` | || 发送对象的 FriendInfo |
| shareMessageTitle | `string` | || 转发标题,不传则默认使用当前小程序的昵称。 FriendInfo |
| shareMessageImg | `string` | || 转发显示图片的链接,可以是网络图片路径(仅 QQ CDN 域名路径)或本地图片文件路径或相对代码包根目录的图片文件路径。显示图片长宽比是 5:4FriendInfo |
| dataAwemeId | `string` | || 跳转抖音号个人页,只支持小程序绑定的品牌号、员工号、合作号 |
| onGetUserInfo | `CommonEventFunction<onGetUserInfoEventDetail>` | || 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与 Taro.getUserInfo 返回的一致<br /><br />生效时机: `open-type="getUserInfo"` |
| onGetAuthorize | `CommonEventFunction` | || 支付宝获取会员基础信息授权回调<br /><br />生效时机:`open-type="getAuthorize"` |
| onContact | `CommonEventFunction<onContactEventDetail>` | || 客服消息回调<br /><br />生效时机:`open-type="contact"` |
Expand All @@ -232,6 +233,7 @@ export default {
| onSubscribe | `CommonEventFunction` | || 订阅消息授权回调,和 open-type 搭配使用,使用时机:open-type="subscribe" |
| onAddFriend | `CommonEventFunction` | || 添加好友的回调 |
| onAddGroupApp | `CommonEventFunction` | || 添加群应用的回调。errCode 错误码:41004(当前用户非管理员或群主,无权操作),41005(超过可添加群应用的群数量) |
| onOpenAwemeUserProfile | `CommonEventFunction` | || 监听跳转抖音号个人页的回调<br /><br />生效时机:`open-type="openAwemeUserProfile"` |

### API 支持度

Expand Down Expand Up @@ -269,6 +271,7 @@ export default {
| ButtonProps.shareMessageFriendInfo | | | | | ✔️ | | | | |
| ButtonProps.shareMessageTitle | | | | | ✔️ | | | | |
| ButtonProps.shareMessageImg | | | | | ✔️ | | | | |
| ButtonProps.dataAwemeId | | | | ✔️ | | | | | |
| ButtonProps.onGetUserInfo | ✔️ | ✔️ | ✔️ | | ✔️ | ✔️ | | | |
| ButtonProps.onGetAuthorize | | | ✔️ | | | | | | |
| ButtonProps.onContact | ✔️ | ✔️ | | | ✔️ | | | | |
Expand All @@ -287,6 +290,7 @@ export default {
| ButtonProps.onSubscribe | | ✔️ | | | | | | | |
| ButtonProps.onAddFriend | | | | | ✔️ | | | | |
| ButtonProps.onAddGroupApp | | | | | ✔️ | | | | |
| ButtonProps.onOpenAwemeUserProfile | | | | ✔️ | | | | | |

### Size

Expand Down Expand Up @@ -329,6 +333,7 @@ open-type 的合法值
| weapp | `{ contact: any; share: any; getPhoneNumber: any; getRealtimePhoneNumber: any; getUserInfo: any; launchApp: any; openSetting: any; feedback: any; chooseAvatar: any; agreePrivacyAuthorization: any; }` | |
| alipay | `{ share: any; getAuthorize: any; contactShare: any; lifestyle: any; }` | 支付宝小程序专属的 open-type 合法值<br />[参考地址](https://opendocs.alipay.com/mini/component/button) |
| qq | `{ share: any; getUserInfo: any; launchApp: any; openSetting: any; feedback: any; openGroupProfile: any; addFriend: any; addColorSign: any; openPublicProfile: any; addGroupApp: any; shareMessageToFriend: any; }` | QQ 小程序专属的 open-type 合法值<br />[参考地址](https://q.qq.com/wiki/develop/miniprogram/component/form/button.html) |
| tt | `{ share: any; getPhoneNumber: any; im: any; platformIm: any; navigateToVideoView: any; openAwemeUserProfile: any; openWebcastRoom: any; addCalendarEvent: any; addShortcut: any; joinGroup: any; privateMessage: any; authorizePrivateMessage: any; }` | TT 小程序专属的 open-type 合法值<br />[参考地址](https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/component/list/button/#open-type-%E7%9A%84%E5%90%88%E6%B3%95%E5%80%BC) |

### Lang

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export default {
| ScrollViewProps.reverse | ✔️ | | | | | | | | |
| ScrollViewProps.cacheExtent | ✔️ | | | | | | | | |
| ScrollViewProps.scrollIntoViewWithinExtent | ✔️ | | | | | | | | |
| ScrollViewProps.scrollIntoViewAlignment | ✔️ | | | | | | | | |
| ScrollViewProps.scrollIntoViewAlignment | ✔️ | | | | | | ✔️ | | |
| ScrollViewProps.onScrollToUpper | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| ScrollViewProps.onScrollToLower | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| ScrollViewProps.onScroll | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-3.x/plugin-mini-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const config = {
- --type
传入平台名称
- --projectPath
传入路径。 此选项优先级为: 终端传入的`--projectPath` > CI 配置的`projectPath` 选项 > [outputRoot 选项](config-detail#outputroot)
传入路径。 此选项优先级为: 终端传入的`--projectPath` > CI 配置的`projectPath` 选项 > [outputRoot 选项](./config-detail#outputroot)

### Hooks 使用(3.6.0 开始支持)

Expand Down
148 changes: 148 additions & 0 deletions versioned_docs/version-3.x/test-utils/fire-event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
---
title: 事件相关 API
---

## fireEvent

`@tarojs/test-utils`目的是关注组件的**用户行为和外部表现,而不是内部实现细节**,所以无论是**vue**还是**react**,本质都是在渲染完成后,通过触发元素的事件,从而响应到内部实现的回调函数。
`fireEvent`内置了常用的事件触发器,通过获取元素 => 触发事件 => 事件响应 来对测试结果进行断言。

### 内置事件

```js
// 获取元素
const ele = testUtils.queries.querySelector('input')
// 触发keyPress事件
testUtils.fireEvent.keyPress(ele, {
key: 'A',
code: 'A',
})
```

```ts
export interface FireEvent {
// Clipboard Events
copy(ele: Element, params?: ClipboardEventInit): void
cut(ele: Element, params?: ClipboardEventInit): void
paste(ele: Element, params?: ClipboardEventInit): void
// Composition Events
compositionEnd(ele: Element, params?: CompositionEventInit): void
compositionStart(ele: Element, params?: CompositionEventInit): void
compositionUpdate(ele: Element, params?: CompositionEventInit): void
// Keyboard Events
keyDown(ele: Element, params?: KeyboardEventInit): void
keyPress(ele: Element, params?: KeyboardEventInit): void
keyUp(ele: Element, params?: KeyboardEventInit): void
// Focus Events
focus(ele: Element, params?: FocusEventInit): void
blur(ele: Element, params?: FocusEventInit): void
focusIn(ele: Element, params?: FocusEventInit): void
focusOut(ele: Element, params?: FocusEventInit): void
// Form Events
change(ele: Element, params?: EventInit): void
input(ele: Element, params?: InputEventInit): void
invalid(ele: Element, params?: EventInit): void
submit(ele: Element, params?: EventInit): void
reset(ele: Element, params?: EventInit): void
// Mouse Events
click(ele: Element, params?: MouseEventInit): void
contextMenu(ele: Element, params?: MouseEventInit): void
dblClick(ele: Element, params?: MouseEventInit): void
doubleClick(ele: Element, params?: MouseEventInit): void
drag(ele: Element, params?: MouseEventInit): void
dragEnd(ele: Element, params?: MouseEventInit): void
dragEnter(ele: Element, params?: MouseEventInit): void
dragExit(ele: Element, params?: MouseEventInit): void
dragLeave(ele: Element, params?: MouseEventInit): void
dragOver(ele: Element, params?: MouseEventInit): void
drop(ele: Element, params?: MouseEventInit): void
mouseDown(ele: Element, params?: MouseEventInit): void
mouseEnter(ele: Element, params?: MouseEventInit): void
mouseLeave(ele: Element, params?: MouseEventInit): void
mouseMove(ele: Element, params?: MouseEventInit): void
mouseOut(ele: Element, params?: MouseEventInit): void
mouseOver(ele: Element, params?: MouseEventInit): void
mouseUp(ele: Element, params?: MouseEventInit): void
// Selection Events
select(ele: Element, params?: EventInit): void
// Touch Events
touchCancel(ele: Element, params?: TouchEventInit): void
touchEnd(ele: Element, params?: TouchEventInit): void
touchMove(ele: Element, params?: TouchEventInit): void
touchStart(ele: Element, params?: TouchEventInit): void
// UI Events
resize(ele: Element, params?: UIEventInit): void
scroll(ele: Element, params?: UIEventInit): void
// Wheel Events
wheel(ele: Element, params?: WheelEventInit): void
// Media Events
abort(ele: Element, params?: EventInit): void
canPlay(ele: Element, params?: EventInit): void
canPlayThrough(ele: Element, params?: EventInit): void
durationChange(ele: Element, params?: EventInit): void
emptied(ele: Element, params?: EventInit): void
encrypted(ele: Element, params?: EventInit): void
ended(ele: Element, params?: EventInit): void
loadedData(ele: Element, params?: EventInit): void
loadedMetadata(ele: Element, params?: EventInit): void
loadStart(ele: Element, params?: ProgressEventInit): void
pause(ele: Element, params?: EventInit): void
play(ele: Element, params?: EventInit): void
playing(ele: Element, params?: EventInit): void
progress(ele: Element, params?: ProgressEventInit): void
rateChange(ele: Element, params?: EventInit): void
seeked(ele: Element, params?: EventInit): void
seeking(ele: Element, params?: EventInit): void
stalled(ele: Element, params?: EventInit): void
suspend(ele: Element, params?: EventInit): void
timeUpdate(ele: Element, params?: EventInit): void
volumeChange(ele: Element, params?: EventInit): void
waiting(ele: Element, params?: EventInit): void
// Events
load(ele: Element, params?: EventInit): void
error(ele: Element, params?: EventInit): void
// Animation Events
animationStart(ele: Element, params?: AnimationEventInit): void
animationEnd(ele: Element, params?: AnimationEventInit): void
animationIteration(ele: Element, params?: AnimationEventInit): void
// Transition Events
transitionCancel(ele: Element, params?: TransitionEventInit): void
transitionEnd(ele: Element, params?: TransitionEventInit): void
transitionRun(ele: Element, params?: TransitionEventInit): void
transitionStart(ele: Element, params?: TransitionEventInit): void
// pointer events
pointerOver(ele: Element, params?: PointerEventInit): void
pointerEnter(ele: Element, params?: PointerEventInit): void
pointerDown(ele: Element, params?: PointerEventInit): void
pointerMove(ele: Element, params?: PointerEventInit): void
pointerUp(ele: Element, params?: PointerEventInit): void
pointerCancel(ele: Element, params?: PointerEventInit): void
pointerOut(ele: Element, params?: PointerEventInit): void
pointerLeave(ele: Element, params?: PointerEventInit): void
gotPointerCapture(ele: Element, params?: PointerEventInit): void
lostPointerCapture(ele: Element, params?: PointerEventInit): void
// history events
popState(ele: Element, params?: PopStateEventInit): void
// window events
offline(ele: Element, params?: EventInit): void
online(ele: Element, params?: EventInit): void
}
```

### 构造事件

除了上述的内置事件外,我们也可以通过`new Event()`来构造一个新的事件类型

```ts
function fireEvent(ele: Element, event: Event)
```

使用案例:

```js
// 获取元素
const ele = testUtils.queries.querySelector('.text')
// 触发一个心的事件
testUtils.fireEvent(ele, new Event())
testUtils.fireEvent(ele, new PointerEvent())
```
Loading

0 comments on commit 4d1f893

Please sign in to comment.