Fix uploader test and refactor makeTestWrapper to accept data fn
This commit is contained in:
@@ -9,6 +9,9 @@ const WrapperComponent = makeTestWrapper({
|
||||
checkboxinput,
|
||||
},
|
||||
templatePath: 'checkbox_input_template.html',
|
||||
data: function() {
|
||||
return { initialvalue: this.initialData }
|
||||
}
|
||||
})
|
||||
|
||||
describe('CheckboxInput Renders Correctly', () => {
|
||||
|
@@ -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')
|
||||
|
Reference in New Issue
Block a user