Fix uploader test and refactor makeTestWrapper to accept data fn

This commit is contained in:
richard-dds
2019-08-05 11:19:21 -04:00
parent 3d414e1a60
commit 81a478915d
7 changed files with 69 additions and 27 deletions

View File

@@ -9,6 +9,9 @@ const WrapperComponent = makeTestWrapper({
checkboxinput,
},
templatePath: 'checkbox_input_template.html',
data: function() {
return { initialvalue: this.initialData }
}
})
describe('CheckboxInput Renders Correctly', () => {

View File

@@ -7,18 +7,24 @@ import { makeTestWrapper } from '../../test_utils/component_test_helpers'
const UploadWrapper = makeTestWrapper({
components: { uploadinput },
templatePath: 'upload_input_template.html',
data: function() {
return { initialvalue: this.initialData.initialvalue, token: this.token }
}
})
const UploadErrorWrapper = makeTestWrapper({
components: { uploadinput },
templatePath: 'upload_input_error_template.html',
data: function() {
return { initialvalue: null, token: null }
}
})
describe('UploadInput Test', () => {
it('should show input and button when no attachment present', () => {
const wrapper = mount(UploadWrapper, {
propsData: {
initialData: null,
initialData: { initialvalue: null, token: "token" },
},
})
@@ -29,7 +35,7 @@ describe('UploadInput Test', () => {
it('should show file name and hide input', () => {
const wrapper = mount(UploadWrapper, {
propsData: {
initialData: 'somepdf.pdf',
initialData: { initialvalue: "somepdf.pdf", token: "token" }
},
})
@@ -41,7 +47,11 @@ describe('UploadInput Test', () => {
})
it('should correctly display error treatment', () => {
const wrapper = mount(UploadErrorWrapper)
const wrapper = mount(UploadErrorWrapper, {
propsData: {
initialData: { initialvalue: "somepdf.pdf", token: "token" }
}
})
const messageArea = wrapper.find('.usa-input__message')
expect(messageArea.html()).toContain('Test Error Message')