fix: storybook story of Comment.vue

This is the best solution that I can think of right now. Sure, it's not
so great to pass a property down from the page component. But at least
it fixes the storybook story, which is something.
This commit is contained in:
roschaefer 2019-10-16 00:50:43 +02:00
parent 2090e3939b
commit 6a50ef6134
5 changed files with 7 additions and 15 deletions

View File

@ -32,9 +32,6 @@ describe('Comment.vue', () => {
truncate: a => a,
removeHtml: a => a,
},
$route: {
hash: '',
},
$scrollTo: jest.fn(),
$apollo: {
mutate: jest.fn().mockResolvedValue({

View File

@ -71,7 +71,7 @@ export default {
mixins: [scrollToAnchor],
data() {
const anchor = `commentId-${this.comment.id}`
const isTarget = this.$route.hash === `#${anchor}`
const isTarget = this.routeHash === `#${anchor}`
return {
anchor,
@ -87,13 +87,9 @@ export default {
HcCommentForm,
},
props: {
post: { type: Object, default: () => {} },
comment: {
type: Object,
default() {
return {}
},
},
routeHash: { type: String, default: () => '' },
post: { type: Object, default: () => ({}) },
comment: { type: Object, default: () => ({}) },
dateTime: { type: [Date, String], default: null },
},
computed: {

View File

@ -42,9 +42,6 @@ describe('CommentList.vue', () => {
truncate: a => a,
removeHtml: a => a,
},
$route: {
hash: '',
},
$scrollTo: jest.fn(),
$apollo: {
queries: {

View File

@ -22,6 +22,7 @@
:key="comment.id"
:comment="comment"
:post="post"
:routeHash="routeHash"
@deleteComment="updateCommentList"
@updateComment="updateCommentList"
/>
@ -38,6 +39,7 @@ export default {
Comment,
},
props: {
routeHash: { type: String, default: () => '' },
post: { type: Object, default: () => {} },
},
methods: {

View File

@ -68,7 +68,7 @@
</ds-space>
<!-- Comments -->
<ds-section slot="footer">
<hc-comment-list :post="post" />
<hc-comment-list :post="post" :routeHash="$route.hash" />
<ds-space margin-bottom="large" />
<hc-comment-form :post="post" @createComment="createComment" />
</ds-section>