Set incoming props as variable names rather than values in test rendering to allow props to be properly passed to component under test

This commit is contained in:
tomdds 2019-07-11 17:52:54 -04:00
parent fd6ad924d9
commit 5234677ad3
3 changed files with 10 additions and 7 deletions

View File

@ -33,10 +33,13 @@ const WrapperComponent = {
name: 'WrapperComponent', name: 'WrapperComponent',
components: { checkboxinput }, components: { checkboxinput },
template: testTemplate, template: testTemplate,
props: {
initialChecked: Boolean,
},
data: function () { data: function () {
return { return {
name: 'testCheck', name: 'testCheck',
initialChecked: true initialchecked: this.initialChecked
} }
} }
} }
@ -50,7 +53,7 @@ describe('CheckboxInput Renders Correctly', () => {
} }
}) })
wrapper.vm.$children[0].$data.isChecked = true // wrapper.vm.$children[0].$data.isChecked = true
expect(wrapper.find('.usa-input input').element.checked).toBe(true) expect(wrapper.find('.usa-input input').element.checked).toBe(true)
}) })

View File

@ -2,14 +2,14 @@
name='testVal' name='testVal'
inline-template inline-template
key='testVal' key='testVal'
v-bind:initial-checked='false' v-bind:initial-checked='initialchecked'
> >
<div> <div>
<div class='usa-input '> <div class='usa-input '>
<fieldset data-ally-disabled="true" v-on:change="onInput" class="usa-input__choices "> <fieldset data-ally-disabled="true" v-on:change="onInput" class="usa-input__choices ">
<legend> <legend>
<input id="testVal" name="testVal" type="checkbox" v-model="isChecked" value="y"> <input checked id="testVal" name="testVal" type="checkbox" v-model="isChecked" value="initialchecked">
<label for="testVal">Hooray!</label> <label for="testVal">Hooray!</label>

View File

@ -1,15 +1,15 @@
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
from wtforms.widgets import CheckboxInput from wtforms.widgets import CheckboxInput
from wtforms.fields import BooleanField from wtforms.fields import StringField
from wtforms import Form from wtforms import Form
env = Environment(loader=FileSystemLoader('templates/components')) env = Environment(loader=FileSystemLoader('templates/components'))
checkbox_template = env.get_template('checkbox_input.html') checkbox_template = env.get_template('checkbox_input.html')
field = BooleanField( field = StringField(
label="Hooray!", label="Hooray!",
default=False, default="initialchecked",
widget=CheckboxInput() widget=CheckboxInput()
) )