From fa5748fbe791823615914073b32f5e8a6cb2119a Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Wed, 29 Jan 2020 17:07:48 -0700 Subject: [PATCH] fix: update attributes for nuxt-link and router-link (#3) * fix attributes for nuxt-link and router-link * style: fix linting issues --- src/components/sys-form-button.vue | 2 +- test/spec/components/sys-form-button.js | 28 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/components/sys-form-button.vue b/src/components/sys-form-button.vue index a34a13c..68cbc0a 100644 --- a/src/components/sys-form-button.vue +++ b/src/components/sys-form-button.vue @@ -83,7 +83,7 @@ export default { return {} } - switch (this.tag) { + switch (this.component) { case 'nuxt-link': case 'router-link': return { to: this.href } diff --git a/test/spec/components/sys-form-button.js b/test/spec/components/sys-form-button.js index 8992bdc..9a58f33 100644 --- a/test/spec/components/sys-form-button.js +++ b/test/spec/components/sys-form-button.js @@ -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"')) +})