提交 6fb95d25 编写于 作者: W wanganxp

补充form和拦截器的测试

上级 fee5e34d
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
<button @click="addInterceptor">添加路由拦截器</button> <button @click="addInterceptor">添加路由拦截器</button>
<button @click="removeInterceptor">移除路由拦截器</button> <button @click="removeInterceptor">移除路由拦截器</button>
<text>点击下方按钮{{msg}}</text> <text>点击下方按钮{{msg}}</text>
<button @click="navigateTo">跳转到测试页面</button> <button @click="navigateTo">navigatorTo API跳转到测试页面</button>
<navigator url="./page1"><button>navigator组件跳转到测试页面</button></navigator>
</view> </view>
</template> </template>
......
...@@ -5,12 +5,14 @@ const DEFAULT_GENDER = '0' ...@@ -5,12 +5,14 @@ const DEFAULT_GENDER = '0'
const DEFAULT_LOVES = ['0'] const DEFAULT_LOVES = ['0']
const DEFAULT_AGE = 18 const DEFAULT_AGE = 18
const DEFAULT_SWITCH = true const DEFAULT_SWITCH = true
const DEFAULT_COMMENT = ''
const CHANGE_NICK_NAME = 'hello' const CHANGE_NICK_NAME = 'hello'
const CHANGE_GENDER = '1' const CHANGE_GENDER = '1'
const CHANGE_LOVES = ['0', '1'] const CHANGE_LOVES = ['0', '1']
const CHANGE_AGE = 50 const CHANGE_AGE = 50
const CHANGE_SWITCH = false const CHANGE_SWITCH = false
const CHANGE_COMMENT = '备注'
describe('form', () => { describe('form', () => {
let page let page
...@@ -35,6 +37,7 @@ describe('form', () => { ...@@ -35,6 +37,7 @@ describe('form', () => {
expect(formData['loves'][1]).toBe(CHANGE_LOVES[1]) expect(formData['loves'][1]).toBe(CHANGE_LOVES[1])
expect(formData['age']).toBe(CHANGE_AGE) expect(formData['age']).toBe(CHANGE_AGE)
expect(formData['switch']).toBe(CHANGE_SWITCH) expect(formData['switch']).toBe(CHANGE_SWITCH)
expect(formData['comment']).toBe(CHANGE_COMMENT)
}) })
it('reset', async () => { it('reset', async () => {
await changeData(page) await changeData(page)
...@@ -56,6 +59,7 @@ describe('form', () => { ...@@ -56,6 +59,7 @@ describe('form', () => {
expect(formData['loves'][0]).toBe(DEFAULT_LOVES[0]) expect(formData['loves'][0]).toBe(DEFAULT_LOVES[0])
expect(formData['age']).toBe(DEFAULT_AGE) expect(formData['age']).toBe(DEFAULT_AGE)
expect(formData['switch']).toBe(DEFAULT_SWITCH) expect(formData['switch']).toBe(DEFAULT_SWITCH)
expect(formData['comment']).toBe(DEFAULT_COMMENT)
}) })
}) })
...@@ -65,7 +69,8 @@ async function changeData(page) { ...@@ -65,7 +69,8 @@ async function changeData(page) {
gender: CHANGE_GENDER, gender: CHANGE_GENDER,
loves: CHANGE_LOVES, loves: CHANGE_LOVES,
age: CHANGE_AGE, age: CHANGE_AGE,
switch: CHANGE_SWITCH switch: CHANGE_SWITCH,
comment:CHANGE_COMMENT
}) })
await page.waitFor(100) await page.waitFor(100)
} }
...@@ -40,6 +40,11 @@ ...@@ -40,6 +40,11 @@
<switch name="switch" :checked="switch" /> <switch name="switch" :checked="switch" />
</view> </view>
</view> </view>
<view class="uni-form-item">
<view class="title">备注</view>
<textarea name="comment" :value="comment" placeholder="请输入备注" style="background: #FFF;"/>
<!-- <textarea class="uni-input" name="comment" :value="comment" placeholder="这个class的写法,导致iOS和Android产生了高度差异"/> -->
</view>
<view class="uni-btn-v flex-row"> <view class="uni-btn-v flex-row">
<button class="btn btn-submit" form-type="submit" type="primary">Submit</button> <button class="btn btn-submit" form-type="submit" type="primary">Submit</button>
<button class="btn btn-reset" type="default" form-type="reset">Reset</button> <button class="btn btn-reset" type="default" form-type="reset">Reset</button>
...@@ -62,6 +67,7 @@ ...@@ -62,6 +67,7 @@
age: 18, age: 18,
loves: ['0'], loves: ['0'],
switch: true, switch: true,
comment:'',
formData: {} as UTSJSONObject formData: {} as UTSJSONObject
} }
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册