Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 部分API使用空实现并补充对应测试用例 #160

Merged
merged 2 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class Index extends React.Component<Props, States> {
textareaControl: [],
hiddenNum: 0,
}
componentDidMount (): void {
componentDidMount(): void {
const buttonList = this.props.buttonList
const inputData: Array<Object> = []
const textareaControl: Array<Boolean> = []
Expand Down Expand Up @@ -107,7 +107,7 @@ export default class Index extends React.Component<Props, States> {
return false
}
}
render () {
render() {
const { buttonList } = this.props
const { inputData, textareaControl, hiddenNum } = this.state
return (
Expand Down Expand Up @@ -158,8 +158,9 @@ export default class Index extends React.Component<Props, States> {
''
)}
<View
className={`api-page-btn ${item.func == null ? 'api-page-btn-uncreate' : ''} ${this.isAdvancedAPI(item.id) ? 'api-page-btn-advanced' : ''
}`}
className={`api-page-btn ${item.func == null ? 'api-page-btn-uncreate' : ''} ${
this.isAdvancedAPI(item.id) ? 'api-page-btn-advanced' : ''
}`}
id={item.id}
onClick={() => {
this.submitData(inputData[apiIndex], item, apiIndex)
Expand Down
37 changes: 33 additions & 4 deletions examples/mini-program-example/src/pages/api/advertising/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { View } from '@tarojs/components'
import ButtonList from '@/components/buttonList'
import { TestConsole } from '@/util/util'
import './index.scss'

/**
Expand All @@ -11,18 +12,46 @@ import './index.scss'

export default class Index extends React.Component {
state = {
ad: {} as Taro.InterstitialAd,
list: [
{
id: 'createRewardedVideoAd',
func: null,
},
{
id: 'createInterstitialAd',
func: null,
inputData: {
adUnitId: '',
},
func: (_, data) => {
TestConsole.consoleTest('Taro.createInterstitialAd')
const ad = Taro.createInterstitialAd(data)
TestConsole.consoleNormal('createInterstitialAd', ad)
this.setState({ ad })
ad.onError((res) => {
TestConsole.consoleNormal('InterstitialAd.onError', res)
})
ad.onLoad((res) => {
TestConsole.consoleNormal('InterstitialAd.onLoad', res)
})
ad.onClose(() => {
TestConsole.consoleNormal('InterstitialAd.onClose')
})
},
},
{
id: 'InterstitialAd',
func: null,
id: 'InterstitialAd.show',
inputData: {
adUnitId: '',
},
func: () => {
TestConsole.consoleTest('InterstitialAd.show')
if (this.state.ad) {
this.state.ad.show().then(() => {
TestConsole.consoleNormal('InterstitialAd.show')
})
}
},
},
{
id: 'RewardedVideoAd',
Expand Down
64 changes: 61 additions & 3 deletions examples/mini-program-example/src/pages/api/forward/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { TestConsole } from '@/util/util'
import ButtonList from '@/components/buttonList'
import './index.scss'

Expand All @@ -18,7 +19,27 @@ export default class Index extends React.Component {
},
{
id: 'showShareMenu',
func: null,
inputData: {
withShareTicket: true,
},
func: (apiIndex, data) => {
TestConsole.consoleTest('Taro.showShareMenu')
Taro.showShareMenu(data).then(() => {
TestConsole.consoleNormal('showShareMenu')
})
Taro.showShareMenu({
...data,
success: (res) => {
TestConsole.consoleSuccess.call(this, res, apiIndex)
},
fail: (res) => {
TestConsole.consoleFail.call(this, res, apiIndex)
},
complete: (res) => {
TestConsole.consoleComplete.call(this, res, apiIndex)
},
})
},
},
{
id: 'showShareImageMenu',
Expand All @@ -42,11 +63,48 @@ export default class Index extends React.Component {
},
{
id: 'hideShareMenu',
func: null,
inputData: {
menus: ['shareAppMessage', 'shareTimeline'],
},
func: (apiIndex, data) => {
TestConsole.consoleTest('Taro.hideShareMenu')
Taro.hideShareMenu(data).then(() => {
TestConsole.consoleNormal('hideShareMenu')
})
Taro.hideShareMenu({
...data,
success: (res) => {
TestConsole.consoleSuccess.call(this, res, apiIndex)
},
fail: (res) => {
TestConsole.consoleFail.call(this, res, apiIndex)
},
complete: (res) => {
TestConsole.consoleComplete.call(this, res, apiIndex)
},
})
},
},
{
id: 'getShareInfo',
func: null,
inputData: {
shareTicket: '',
},
func: (apiIndex, data) => {
TestConsole.consoleTest('Taro.getShareInfo')
Taro.getShareInfo({
...data,
success: (res) => {
TestConsole.consoleSuccess.call(this, res, apiIndex)
},
fail: (res) => {
TestConsole.consoleFail.call(this, res, apiIndex)
},
complete: (res) => {
TestConsole.consoleComplete.call(this, res, apiIndex)
},
})
},
},
{
id: 'authPrivateMessage',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,41 @@ export default class Index extends React.Component {
},
{
id: 'enableAlertBeforeUnload',
func: null,
inputData: {
message: '空实现',
},
func: (apiIndex, data) => {
TestConsole.consoleTest('Taro.enableAlertBeforeUnload')
Taro.enableAlertBeforeUnload({
...data,
success: (res) => {
TestConsole.consoleSuccess.call(this, res, apiIndex)
},
fail: (res) => {
TestConsole.consoleFail.call(this, res, apiIndex)
},
complete: (res) => {
TestConsole.consoleComplete.call(this, res, apiIndex)
},
})
},
},
{
id: 'disableAlertBeforeUnload',
func: null,
func: (apiIndex) => {
TestConsole.consoleTest('Taro.disableAlertBeforeUnload')
Taro.disableAlertBeforeUnload({
success: (res) => {
TestConsole.consoleSuccess.call(this, res, apiIndex)
},
fail: (res) => {
TestConsole.consoleFail.call(this, res, apiIndex)
},
complete: (res) => {
TestConsole.consoleComplete.call(this, res, apiIndex)
},
})
},
},
],
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { TestConsole } from '@/util/util'
import ButtonList from '@/components/buttonList'
import './index.scss'

Expand All @@ -18,17 +19,21 @@ export default class Index extends React.Component {
},
{
id: 'setNavigationBarTitle',
func: (apiIndex) => {
inputData: {
title: '当前页面',
},
func: (apiIndex, data) => {
TestConsole.consoleTest('Taro.setNavigationBarTitle')
Taro.setNavigationBarTitle({
title: '当前页面',
success: function (res) {
console.log('setNavigationBarTitle success ', res)
...data,
success: (res) => {
TestConsole.consoleSuccess.call(this, res, apiIndex)
},
fail: function (res) {
console.log('setNavigationBarTitle fail ', res)
fail: (res) => {
TestConsole.consoleFail.call(this, res, apiIndex)
},
complete: function (res) {
console.log('setNavigationBarTitle complete ', res)
complete: (res) => {
TestConsole.consoleComplete.call(this, res, apiIndex)
},
})
},
Expand All @@ -43,7 +48,23 @@ export default class Index extends React.Component {
},
{
id: 'hideHomeButton',
func: null,
func: (apiIndex) => {
TestConsole.consoleTest('Taro.hideHomeButton')
Taro.hideHomeButton().then(() => {
TestConsole.consoleNormal('hideHomeButton')
})
Taro.hideHomeButton({
success: (res) => {
TestConsole.consoleSuccess.call(this, res, apiIndex)
},
fail: (res) => {
TestConsole.consoleFail.call(this, res, apiIndex)
},
complete: (res) => {
TestConsole.consoleComplete.call(this, res, apiIndex)
},
})
},
},
],
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { View } from '@tarojs/components'
import { TestConsole } from '@/util/util'
import ButtonList from '@/components/buttonList'
import './index.scss'

Expand All @@ -14,7 +15,24 @@ export default class Index extends React.Component {
list: [
{
id: 'setTopBarText',
func: null,
inputData: {
text: 'hello, world!',
},
func: (apiIndex, data) => {
TestConsole.consoleTest('Taro.setTopBarText')
Taro.setTopBarText({
...data,
success: (res) => {
TestConsole.consoleSuccess.call(this, res, apiIndex)
},
fail: (res) => {
TestConsole.consoleFail.call(this, res, apiIndex)
},
complete: (res) => {
TestConsole.consoleComplete.call(this, res, apiIndex)
},
})
},
},
],
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { View, Button, Text } from '@tarojs/components'
import { View } from '@tarojs/components'
import ButtonList from '@/components/buttonList'
import './index.scss'
import { TestConsole } from '@/util/util'
import apiImage from '@/assets/tab/api.png'
import apiSelectImage from '@/assets/tab/api_select.png'
import './index.scss'

/**
* 界面-Tab Bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class Index extends React.Component {
func: (apiIndex) => {
TestConsole.consoleTest('createInnerAudioContext_h5')
innercontext = Taro.createInnerAudioContext({
useWebAudioImplement: true
useWebAudioImplement: true,
})
TestConsole.consoleNormal('create innerAudioContext :', innercontext)
},
Expand All @@ -87,7 +87,7 @@ export default class Index extends React.Component {
loop: false,
volume: 1,
playbackRate: 1,
referrerPolicy: 'origin'
referrerPolicy: 'origin',
},
func: (apiIndex, data) => {
TestConsole.consoleTest('InnerAudioContext_set')
Expand Down Expand Up @@ -277,7 +277,7 @@ export default class Index extends React.Component {
},
],
}
render () {
render() {
const { list } = this.state
return (
<View className='api-page'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { View, Button, Text } from '@tarojs/components'
import { View } from '@tarojs/components'
import ButtonList from '@/components/buttonList'
import { TestConsole } from '@/util/util'
import './index.scss'

/**
Expand All @@ -14,7 +15,10 @@ export default class Index extends React.Component {
list: [
{
id: 'getAccountInfoSync',
func: null,
func: () => {
TestConsole.consoleTest('Taro.getAccountInfoSync')
TestConsole.consoleNormal('Taro.getAccountInfoSync', Taro.getAccountInfoSync())
},
},
],
}
Expand Down
Loading