Skip to content

Commit

Permalink
fix(MdField): preserve the name attribute on change (#1385)
Browse files Browse the repository at this point in the history
  • Loading branch information
jastkand authored and marcosmoura committed Jan 12, 2018
1 parent ff341a2 commit 0a83834
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/MdField/MdFieldMixin.js
Expand Up @@ -2,6 +2,7 @@ export default {
props: {
value: {},
placeholder: String,
name: String,
maxlength: [String, Number],
readonly: Boolean,
required: Boolean,
Expand Down
33 changes: 33 additions & 0 deletions src/components/MdField/MdInput/MdInput.test.js
@@ -0,0 +1,33 @@
import Vue from 'vue'
import mountTemplate from 'test/utils/mountTemplate'
import MdFieldModule from 'components/MdField'
import MdField from '../MdField.vue'

Vue.use(MdFieldModule)

test('should render the input', async () => {
const template = `
<md-field>
<md-input></md-input>
</md-field>
`
const wrapper = await mountTemplate(MdField, template)

expect(wrapper.contains('.md-input')).toBe(true)
})

test('should preserve a value of the "name" attribute on change', async () => {
const template = `
<md-field>
<md-input name="details"></md-input>
</md-field>
`
const wrapper = await mountTemplate(MdField, template)
const input = wrapper.find('.md-input')[0]

input.trigger('change')

await wrapper.vm.$nextTick()

expect(input.getAttribute('name')).toBe('details')
})

0 comments on commit 0a83834

Please sign in to comment.