34de4ba6dc
* Adds support form FormulateError form errors * Adds support for form-errors prop Also includes tests for both named-form-errors as well, form-errors prop, positioning form errors with the <FormulateErrors /> component, and allowing multiple <FormulateErrors /> * Adds form error support, error handling, and supporting tests * Remove unused util functions * Adds german localization locales/de.js (#14) * Create de.js * Added startsWith and endsWith * adds build process for localization support, removes dist * Adds danish localization * fixes bug that resulted in validation failing if run more than once Credit to @luan-nk-nguyen for discovering the bug * Moves locales to vue-formulate-i18n * Adds dist files for locales * Adds vue-formulate-i18n 1.0.1 * Uses i18n 1.0.3 * Build files * Fixes #19 * Update src/locales/README.md Co-Authored-By: Andrew Boyd <andrew@wearebraid.com> * changes v-html to v-text for error message output credit to @skix123 for the bug report! Co-authored-by: Andrew Boyd <andrew@wearebraid.com>
44 lines
1.7 KiB
JavaScript
44 lines
1.7 KiB
JavaScript
import Vue from 'vue'
|
|
import { mount } from '@vue/test-utils'
|
|
import flushPromises from 'flush-promises'
|
|
import Formulate from '../../src/Formulate.js'
|
|
import FileUpload from '../../src/FileUpload.js'
|
|
import FormulateInput from '@/FormulateInput.vue'
|
|
import FormulateInputFile from '@/inputs/FormulateInputFile.vue'
|
|
|
|
Vue.use(Formulate)
|
|
|
|
describe('FormulateInputFile', () => {
|
|
|
|
it('type "file" renders a file element', () => {
|
|
const wrapper = mount(FormulateInput, { propsData: { type: 'file' } })
|
|
expect(wrapper.contains(FormulateInputFile)).toBe(true)
|
|
})
|
|
|
|
it('type "image" renders a file element', () => {
|
|
const wrapper = mount(FormulateInput, { propsData: { type: 'image' } })
|
|
expect(wrapper.contains(FormulateInputFile)).toBe(true)
|
|
})
|
|
|
|
it('forces an error-behavior live mode when upload-behavior is live and it has content', () => {
|
|
const wrapper = mount(FormulateInput, { propsData: { type: 'image', validation: 'mime:image/jpeg', value: [{ url: 'img.jpg' }] } })
|
|
expect(wrapper.vm.showValidationErrors).toBe(true)
|
|
})
|
|
|
|
it('wont show errors when upload-behavior is live and it is required but empty', () => {
|
|
const wrapper = mount(FormulateInput, { propsData: { type: 'image', validation: 'required|mime:image/jpeg' } })
|
|
expect(wrapper.vm.showValidationErrors).toBe(false)
|
|
})
|
|
|
|
/**
|
|
* ===========================================================================
|
|
* Currently there appears to be no way to properly mock upload data in
|
|
* vue-test-utils because JSDom doesn't implement DataTransfer:
|
|
*
|
|
* https://stackoverflow.com/questions/48993134/how-to-test-input-file-with-jest-and-vue-test-utils
|
|
*/
|
|
// it('type "image" renders a file element', async () => {
|
|
|
|
// })
|
|
})
|