diff --git a/pages/component/form/form.test.js b/pages/component/form/form.test.js index ed51aa5505a983bdb3accb3b286c7e7b7363fe07..faa9024b25d3c5d4ea861e6c97a919ac0ce8798a 100644 --- a/pages/component/form/form.test.js +++ b/pages/component/form/form.test.js @@ -28,7 +28,8 @@ describe('form', () => { await page.waitFor(200) const { - formData + formData, + testVerifySubmit } = await page.data() expect(formData['nickname']).toBe(CHANGE_NICK_NAME) @@ -38,6 +39,8 @@ describe('form', () => { expect(formData['age']).toBe(CHANGE_AGE) expect(formData['switch']).toBe(CHANGE_SWITCH) expect(formData['comment']).toBe(CHANGE_COMMENT) + + expect(testVerifySubmit).toBe(true) }) it('reset', async () => { await changeData(page) @@ -51,7 +54,8 @@ describe('form', () => { await page.waitFor(100) const { - formData + formData, + testVerifyReset } = await page.data() expect(formData['nickname']).toBe(DEFAULT_NICK_NAME) @@ -60,6 +64,8 @@ describe('form', () => { expect(formData['age']).toBe(DEFAULT_AGE) expect(formData['switch']).toBe(DEFAULT_SWITCH) expect(formData['comment']).toBe(DEFAULT_COMMENT) + + expect(testVerifyReset).toBe(true) }) }) diff --git a/pages/component/form/form.uvue b/pages/component/form/form.uvue index 49f53e65bb0ec7bfd68a9816f198472c851cfadc..664b38d3a69c9fd84ad80c30a91b4ccc1f58b9a5 100644 --- a/pages/component/form/form.uvue +++ b/pages/component/form/form.uvue @@ -68,7 +68,10 @@ loves: ['0'], switch: true, comment:'', - formData: {} as UTSJSONObject + formData: {} as UTSJSONObject, + // 仅测试 + testVerifySubmit: false, + testVerifyReset: false, } }, computed: { @@ -78,10 +81,18 @@ }, methods: { onFormSubmit: function (e : UniFormSubmitEvent) { + console.log(e.target?.tagName ?? '123'); + console.log(e.type); this.formData = e.detail.value + + // 仅测试 + this.testVerifySubmit = (e.type == 'submit' && (e.target?.tagName ?? '') == "FORM") }, - onFormReset: function (_ : UniFormResetEvent) { + onFormReset: function (e : UniFormResetEvent) { this.formData = {} + + // 仅测试 + this.testVerifyReset = (e.type == 'reset' && (e.target?.tagName ?? '') == "FORM") } } }