Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async handleCopy (disabled) {
if (disabled) {
return false
}
try {
const validator = new Validator()
const validPromise = []
this.selection.forEach(row => {
const ip = row.name.split('_')[0]
validPromise.push(new Promise(async resolve => {
const { valid } = await validator.verify(ip, MULTIPLE_IP_REGEXP)
resolve({ valid, ip })
}))
})
const results = await Promise.all(validPromise)
const validResult = results.filter(result => result.valid).map(result => result.ip)
const unique = [...new Set(validResult)]
if (unique.length) {
await this.$copyText(unique.join('\n'))
this.$success(this.$t('复制成功'))
} else {
this.$warn(this.$t('暂无可复制的IP'))
import Helpers from 'mwangaben-vthelpers'
import VeeValidate from 'vee-validate'
import { mount, createLocalVue } from '@vue/test-utils'
import { slug } from '@/helpers'
import Form from '@/components/Form'
const v = new VeeValidate.Validator()
const localVue = createLocalVue()
localVue.use(VeeValidate)
let wrapper, b
const FORM_NAME = 'testFormName'
const MIN_LENGTH = 10
const LABEL_INPUT = 'test input'
const INPUT_NUMBER = 'input[name=number]'
const INPUT_NUMBER_PROPS = {
label: 'Number',
type: 'number',
min: 18,
max: 99
}
describe('Form Error', () => {
import Helpers from 'mwangaben-vthelpers'
import VeeValidate from 'vee-validate'
import { mount, createLocalVue } from '@vue/test-utils'
import flatten from 'ramda/src/flatten'
import pickAll from 'ramda/src/pickAll'
import map from 'ramda/src/map'
import { slug } from '@/helpers'
import Form from '@/components/Form'
import fields from './fields'
const v = new VeeValidate.Validator()
const localVue = createLocalVue()
localVue.use(VeeValidate)
localVue.filter('slugify', str => slug(str))
let wrapper, b
const $inputSubmit = 'input[type=submit]'
const $reset = 'input[type=reset]'
const $inputFirstName = 'input[name=first-name]'
const $inputLastName = 'input[name=last-name]'
const $inputPassword = 'input[name=password]'
const $errorMessage = '.help.is-danger'
const $errorIcon = '.fa-exclamation-triangle'
const FORM_NAME = 'testFormName'
const DEFAULT_VALUE = 'test'
const EMAIL_VALUE = `${DEFAULT_VALUE}@aol.fr`
created() {
this.validator = new Validator({
email: 'required|email',
name: 'required|alpha|min:3'
});
this.$set(this, 'errors', this.validator.errors);
}
};
import Helpers from 'mwangaben-vthelpers'
import VeeValidate from 'vee-validate'
import { mount, createLocalVue } from '@vue/test-utils'
import Form from '@/components/Form'
const v = new VeeValidate.Validator()
const localVue = createLocalVue()
localVue.use(VeeValidate)
let wrapper, b
const FORM_NAME = 'testFormName'
describe('custom css class', () => {
beforeEach(() => {
wrapper = mount(Form, {
localVue,
provide: () => ({ $validator: v }),
propsData: {
formFields: [{ label: 'default' }],
formName: FORM_NAME
}
})
import Helpers from 'mwangaben-vthelpers'
import VeeValidate from 'vee-validate'
import { mount, createLocalVue } from '@vue/test-utils'
import Form from '@/components/Form'
const v = new VeeValidate.Validator()
const localVue = createLocalVue()
localVue.use(VeeValidate)
let wrapper, b
const FORM_NAME = 'testFormName'
const htmlContainer = '[data-test=htmlContentFromFormFields]'
describe('Form with html content inside json', () => {
beforeEach(() => {
wrapper = mount(Form, {
localVue,
provide: () => ({ $validator: v }),
propsData: {
formFields: [{ label: 'defaultLabel' }],
formName: FORM_NAME