From 055b79bfe224a3ab994a666989981ec418c1aa7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Wed, 17 Apr 2019 01:46:29 +0200 Subject: [PATCH] RemoveLinks is better suited as a filter Unfortunately with `v-html` you cannot use filters directly in handlebars. See: https://github.com/nuxt/nuxt.js/issues/231 I also fixed the tests even **without** mocking vue-filters.js plugin :+1: --- webapp/components/PostCard/index.vue | 3 +-- webapp/components/PostCard/spec.js | 2 ++ .../notifications/Notification/index.vue | 13 ++++++------- .../components/notifications/Notification/spec.js | 2 ++ .../notifications/NotificationList/spec.js | 2 ++ .../notifications/NotificationMenu/spec.js | 2 ++ webapp/mixins/removeLinks.js | 15 --------------- webapp/plugins/vue-filters.js | 13 ++++++++++++- 8 files changed, 27 insertions(+), 25 deletions(-) delete mode 100644 webapp/mixins/removeLinks.js diff --git a/webapp/components/PostCard/index.vue b/webapp/components/PostCard/index.vue index 6cf5b5d7c..acddba5d6 100644 --- a/webapp/components/PostCard/index.vue +++ b/webapp/components/PostCard/index.vue @@ -76,7 +76,6 @@ import HcUser from '~/components/User' import ContentMenu from '~/components/ContentMenu' import { randomBytes } from 'crypto' -import RemoveLinks from '~/mixins/removeLinks.js' import { mapGetters } from 'vuex' export default { @@ -96,7 +95,7 @@ export default { user: 'auth/user' }), excerpt() { - return RemoveLinks.methods.removeLinks(this.post.contentExcerpt) + return this.$filters.removeLinks(this.post.contentExcerpt) }, isAuthor() { const { author } = this.post diff --git a/webapp/components/PostCard/spec.js b/webapp/components/PostCard/spec.js index cb1be45ee..1914733c0 100644 --- a/webapp/components/PostCard/spec.js +++ b/webapp/components/PostCard/spec.js @@ -2,11 +2,13 @@ import { config, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils' import PostCard from '.' import Styleguide from '@human-connection/styleguide' import Vuex from 'vuex' +import Filters from '~/plugins/vue-filters' const localVue = createLocalVue() localVue.use(Vuex) localVue.use(Styleguide) +localVue.use(Filters) config.stubs['no-ssr'] = '' config.stubs['v-popover'] = '' diff --git a/webapp/components/notifications/Notification/index.vue b/webapp/components/notifications/Notification/index.vue index 14f660ed6..40b7d9405 100644 --- a/webapp/components/notifications/Notification/index.vue +++ b/webapp/components/notifications/Notification/index.vue @@ -2,11 +2,11 @@ - + {{ $t("notifications.menu.mentioned") }} @@ -38,7 +38,6 @@