Should reset reCAPTCHA (fix #28)

This commit is contained in:
Pig Fang 2019-03-24 11:43:19 +08:00
parent a3f3e11927
commit d5903f6412
2 changed files with 16 additions and 2 deletions

View File

@ -1,7 +1,11 @@
<template>
<div v-if="recaptcha" class="row">
<div class="col-xs-12" style="padding-bottom: 5px">
<vue-recaptcha :sitekey="recaptcha" @verify="$emit('change', $event)" />
<vue-recaptcha
ref="recaptcha"
:sitekey="recaptcha"
@verify="$emit('change', $event)"
/>
</div>
</div>
<div v-else class="row">
@ -52,7 +56,11 @@ export default {
},
methods: {
refreshCaptcha() {
this.time = Date.now()
if (this.recaptcha) {
this.$refs.recaptcha.reset()
} else {
this.time = Date.now()
}
},
},
}

View File

@ -1,3 +1,4 @@
import Vue from 'vue'
import { mount } from '@vue/test-utils'
import Captcha from '@/components/Captcha.vue'
@ -7,6 +8,11 @@ test('display recaptcha', () => {
expect(wrapper.find('img').exists()).toBeFalse()
})
test('refresh recaptcha', () => {
const wrapper = mount<Vue & { refreshCaptcha(): void }>(Captcha)
wrapper.vm.refreshCaptcha()
})
test('display characters captcha', () => {
blessing.extra = {}
const wrapper = mount(Captcha)