Fix formatting
This commit is contained in:
parent
38a01f7db3
commit
0682411954
@ -6,7 +6,7 @@ import { makeTestWrapper } from '../../test_utils/component_test_helpers'
|
|||||||
|
|
||||||
const WrapperComponent = makeTestWrapper({
|
const WrapperComponent = makeTestWrapper({
|
||||||
components: {
|
components: {
|
||||||
checkboxinput
|
checkboxinput,
|
||||||
},
|
},
|
||||||
templatePath: 'checkbox_input_template.html',
|
templatePath: 'checkbox_input_template.html',
|
||||||
})
|
})
|
||||||
@ -16,8 +16,8 @@ describe('CheckboxInput Renders Correctly', () => {
|
|||||||
const wrapper = mount(WrapperComponent, {
|
const wrapper = mount(WrapperComponent, {
|
||||||
propsData: {
|
propsData: {
|
||||||
name: 'testCheck',
|
name: 'testCheck',
|
||||||
initialData: true
|
initialData: true,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
expect(wrapper.find('.usa-input input').element.checked).toBe(true)
|
expect(wrapper.find('.usa-input input').element.checked).toBe(true)
|
||||||
})
|
})
|
||||||
@ -26,8 +26,8 @@ describe('CheckboxInput Renders Correctly', () => {
|
|||||||
const wrapper = mount(WrapperComponent, {
|
const wrapper = mount(WrapperComponent, {
|
||||||
propsData: {
|
propsData: {
|
||||||
name: 'testCheck',
|
name: 'testCheck',
|
||||||
initialData: false
|
initialData: false,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
expect(wrapper.find('.usa-input input').element.checked).toBe(false)
|
expect(wrapper.find('.usa-input input').element.checked).toBe(false)
|
||||||
})
|
})
|
||||||
|
@ -6,20 +6,20 @@ import { makeTestWrapper } from '../../test_utils/component_test_helpers'
|
|||||||
|
|
||||||
const UploadWrapper = makeTestWrapper({
|
const UploadWrapper = makeTestWrapper({
|
||||||
components: { uploadinput },
|
components: { uploadinput },
|
||||||
templatePath: 'upload_input_template.html'
|
templatePath: 'upload_input_template.html',
|
||||||
})
|
})
|
||||||
|
|
||||||
const UploadErrorWrapper = makeTestWrapper({
|
const UploadErrorWrapper = makeTestWrapper({
|
||||||
components: { uploadinput },
|
components: { uploadinput },
|
||||||
templatePath: 'upload_input_error_template.html'
|
templatePath: 'upload_input_error_template.html',
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('UploadInput Test', () => {
|
describe('UploadInput Test', () => {
|
||||||
it('should show input and button when no attachment present', () => {
|
it('should show input and button when no attachment present', () => {
|
||||||
const wrapper = mount(UploadWrapper, {
|
const wrapper = mount(UploadWrapper, {
|
||||||
propsData: {
|
propsData: {
|
||||||
initialData: null
|
initialData: null,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const fileInput = wrapper.find('input[type=file]').element
|
const fileInput = wrapper.find('input[type=file]').element
|
||||||
@ -29,8 +29,8 @@ describe('UploadInput Test', () => {
|
|||||||
it('should show file name and hide input', () => {
|
it('should show file name and hide input', () => {
|
||||||
const wrapper = mount(UploadWrapper, {
|
const wrapper = mount(UploadWrapper, {
|
||||||
propsData: {
|
propsData: {
|
||||||
initialData: 'somepdf.pdf'
|
initialData: 'somepdf.pdf',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const fileInput = wrapper.find('input[type=file]').element
|
const fileInput = wrapper.find('input[type=file]').element
|
||||||
|
@ -16,8 +16,11 @@ to be passed as a prop to checkboxinput at mount time
|
|||||||
v-bind:initial-checked='initialvalue'
|
v-bind:initial-checked='initialvalue'
|
||||||
>
|
>
|
||||||
*/
|
*/
|
||||||
const makeTestWrapper = ({components, templatePath}) => {
|
const makeTestWrapper = ({ components, templatePath }) => {
|
||||||
const templateString = fs.readFileSync(`js/test_templates/${templatePath}`, 'utf-8')
|
const templateString = fs.readFileSync(
|
||||||
|
`js/test_templates/${templatePath}`,
|
||||||
|
'utf-8'
|
||||||
|
)
|
||||||
|
|
||||||
const WrapperComponent = {
|
const WrapperComponent = {
|
||||||
name: 'WrapperComponent',
|
name: 'WrapperComponent',
|
||||||
@ -26,14 +29,12 @@ const makeTestWrapper = ({components, templatePath}) => {
|
|||||||
props: ['initialData'],
|
props: ['initialData'],
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
initialvalue: this.initialData
|
initialvalue: this.initialData,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return WrapperComponent
|
return WrapperComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export { makeTestWrapper }
|
||||||
makeTestWrapper
|
|
||||||
}
|
|
||||||
|
@ -12,35 +12,33 @@ from wtforms import Form
|
|||||||
|
|
||||||
from atst.filters import iconSvg
|
from atst.filters import iconSvg
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates'))
|
env = Environment(loader=FileSystemLoader("templates"))
|
||||||
|
|
||||||
env.filters['iconSvg'] = iconSvg
|
env.filters["iconSvg"] = iconSvg
|
||||||
|
|
||||||
# override tojson as identity function to prevent
|
# override tojson as identity function to prevent
|
||||||
# wrapping strings in extra quotes
|
# wrapping strings in extra quotes
|
||||||
env.filters['tojson'] = lambda x: x
|
env.filters["tojson"] = lambda x: x
|
||||||
|
|
||||||
|
|
||||||
class InitialValueForm(Form):
|
class InitialValueForm(Form):
|
||||||
datafield = StringField(
|
datafield = StringField(label="initialvalue value", default="initialvalue")
|
||||||
label="initialvalue value",
|
|
||||||
default="initialvalue"
|
|
||||||
)
|
|
||||||
|
|
||||||
errorfield = StringField(
|
errorfield = StringField(
|
||||||
label="error",
|
label="error", validators=[InputRequired(message="Test Error Message")]
|
||||||
validators=[InputRequired(message="Test Error Message")]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
checkbox_template = env.get_template('components/checkbox_input.html')
|
|
||||||
ci_macro = getattr(checkbox_template.module, 'CheckboxInput')
|
checkbox_template = env.get_template("components/checkbox_input.html")
|
||||||
|
ci_macro = getattr(checkbox_template.module, "CheckboxInput")
|
||||||
checkbox_input_form = InitialValueForm()
|
checkbox_input_form = InitialValueForm()
|
||||||
checkbox_input_form.datafield.widget = CheckboxInput()
|
checkbox_input_form.datafield.widget = CheckboxInput()
|
||||||
rendered_checkbox_macro = ci_macro(checkbox_input_form.datafield)
|
rendered_checkbox_macro = ci_macro(checkbox_input_form.datafield)
|
||||||
with open("js/test_templates/checkbox_input_template.html", "w") as fh:
|
with open("js/test_templates/checkbox_input_template.html", "w") as fh:
|
||||||
fh.write(rendered_checkbox_macro)
|
fh.write(rendered_checkbox_macro)
|
||||||
|
|
||||||
upload_template = env.get_template('components/upload_input.html')
|
upload_template = env.get_template("components/upload_input.html")
|
||||||
up_macro = getattr(upload_template.module, 'UploadInput')
|
up_macro = getattr(upload_template.module, "UploadInput")
|
||||||
rendered_upload_macro = up_macro(InitialValueForm().datafield)
|
rendered_upload_macro = up_macro(InitialValueForm().datafield)
|
||||||
with open("js/test_templates/upload_input_template.html", "w") as fh:
|
with open("js/test_templates/upload_input_template.html", "w") as fh:
|
||||||
fh.write(rendered_upload_macro)
|
fh.write(rendered_upload_macro)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user