From 6ac21642fa00aa3da37f0c9a73d61dbd64f45aab Mon Sep 17 00:00:00 2001 From: Justin Schroeder Date: Thu, 27 Feb 2020 23:39:44 -0500 Subject: [PATCH] Initial file upload tests --- test/FormulateInputFile.test.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/FormulateInputFile.test.js diff --git a/test/FormulateInputFile.test.js b/test/FormulateInputFile.test.js new file mode 100644 index 0000000..5b82a2a --- /dev/null +++ b/test/FormulateInputFile.test.js @@ -0,0 +1,33 @@ +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) + }) + + /** + * =========================================================================== + * 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 () => { + + // }) +})