Skip to content

Commit

Permalink
fix: update attributes for nuxt-link and router-link (#3)
Browse files Browse the repository at this point in the history
* fix attributes for nuxt-link and router-link

* style: fix linting issues
  • Loading branch information
btkostner authored Jan 30, 2020
1 parent b4daa73 commit fa5748f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/sys-form-button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default {
return {}
}
switch (this.tag) {
switch (this.component) {
case 'nuxt-link':
case 'router-link':
return { to: this.href }
Expand Down
28 changes: 28 additions & 0 deletions test/spec/components/sys-form-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,31 @@ test('renders as router-link if not in a nuxt app', (t) => {
t.log(button.html())
t.true(button.contains('router-link'))
})

test('uses to prop when rendering as a router-link', (t) => {
const button = shallowMount(SysFormButton, {
propsData: {
href: '/test',
tag: 'router-link'
}
})

const html = button.html()

t.log(html)
t.true(html.includes('to="/test"'))
})

test('uses to prop when rendering as a nuxt-link', (t) => {
const button = shallowMount(SysFormButton, {
propsData: {
href: '/test',
tag: 'nuxt-link'
}
})

const html = button.html()

t.log(html)
t.true(html.includes('to="/test"'))
})

0 comments on commit fa5748f

Please sign in to comment.