diff --git a/webapp/components/SocialMedia/SocialMedia.spec.js b/webapp/components/SocialMedia/SocialMedia.spec.js
new file mode 100644
index 000000000..420fbeaf2
--- /dev/null
+++ b/webapp/components/SocialMedia/SocialMedia.spec.js
@@ -0,0 +1,97 @@
+import { config, mount } from '@vue/test-utils'
+import SocialMedia from './SocialMedia.vue'
+
+config.stubs['ds-space'] = ''
+config.stubs['ds-text'] = ''
+
+describe('SocialMedia.vue', () => {
+ let propsData
+ let mocks
+
+ beforeEach(() => {
+ propsData = {}
+
+ mocks = {
+ $t: jest.fn(),
+ }
+ })
+
+ describe('mount', () => {
+ const Wrapper = () => {
+ return mount(SocialMedia, { propsData, mocks })
+ }
+
+ describe('socialMedia card title', () => {
+ beforeEach(() => {
+ propsData.userName = 'Jenny Rostock'
+ propsData.user = {
+ socialMedia: [
+ {
+ id: 'ee1e8ed6-fbef-4bcf-b411-a12926f2ea1e',
+ url: 'https://www.instagram.com/nimitbhargava',
+ __typename: 'SocialMedia',
+ },
+ ],
+ }
+ })
+
+ it('renders socialMedia card title', () => {
+ Wrapper()
+ expect(mocks.$t).toHaveBeenCalledWith('profile.socialMedia')
+ })
+ })
+
+ describe('socialMedia links', () => {
+ let wrapper
+
+ beforeEach(() => {
+ propsData.userName = 'Jenny Rostock'
+ propsData.user = {
+ socialMedia: [
+ {
+ id: 'ee1e8ed6-fbef-4bcf-b411-a12926f2ea1e',
+ url: 'https://www.instagram.com/nimitbhargava',
+ __typename: 'SocialMedia',
+ },
+ {
+ id: 'dc91aecb-3289-47d0-8770-4b24eb24fd9c',
+ url: 'https://www.facebook.com/NimitBhargava',
+ __typename: 'SocialMedia',
+ },
+ {
+ id: 'db1dc400-9303-4b43-9451-87dcac13b913',
+ url: 'https://www.youtube.com/channel/UCu3GiKBFn5I07V9hBxF2CRA',
+ __typename: 'SocialMedia',
+ },
+ ],
+ }
+ // Now assign wrapper
+ wrapper = Wrapper()
+ })
+
+ it('shows 3 social media links', () => {
+ expect(wrapper.findAll('a')).toHaveLength(3)
+ })
+
+ it('renders a social media link', () => {
+ const link = wrapper.findAll('a').at(0)
+ expect(link.attributes('href')).toEqual('https://www.instagram.com/nimitbhargava')
+ })
+
+ it('shows the first favicon', () => {
+ const favicon = wrapper.findAll('a').at(0).find('img')
+ expect(favicon.attributes('src')).toEqual('https://www.instagram.com/favicon.ico')
+ })
+
+ it('shows the second favicon', () => {
+ const favicon = wrapper.findAll('a').at(1).find('img')
+ expect(favicon.attributes('src')).toEqual('https://www.facebook.com/favicon.ico')
+ })
+
+ it('shows the last favicon', () => {
+ const favicon = wrapper.findAll('a').at(-1).find('img')
+ expect(favicon.attributes('src')).toEqual('https://www.youtube.com/favicon.ico')
+ })
+ })
+ })
+})
diff --git a/webapp/components/SocialMedia/SocialMedia.vue b/webapp/components/SocialMedia/SocialMedia.vue
new file mode 100644
index 000000000..e7f2b6a3b
--- /dev/null
+++ b/webapp/components/SocialMedia/SocialMedia.vue
@@ -0,0 +1,49 @@
+
+
+
+
+
+ {{ $t('profile.socialMedia') }} {{ userName | truncate(15) }}?
+
+
+
+
+
+ {{ link.username }}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue
index a4cabeaa6..5222deb1f 100644
--- a/webapp/pages/profile/_id/_slug.vue
+++ b/webapp/pages/profile/_id/_slug.vue
@@ -103,23 +103,7 @@
type="following"
@fetchAllConnections="fetchAllConnections"
/>
-
-
-
-
- {{ $t('profile.socialMedia') }} {{ userName | truncate(15) }}?
-
-
-
-
-
- {{ link.username }}
-
-
-
-
-
-
+
@@ -243,6 +227,7 @@ import { muteUser, unmuteUser } from '~/graphql/settings/MutedUsers'
import { blockUser, unblockUser } from '~/graphql/settings/BlockedUsers'
import PostMutations from '~/graphql/PostMutations'
import UpdateQuery from '~/components/utils/UpdateQuery'
+import SocialMedia from '~/components/SocialMedia/SocialMedia'
const tabToFilterMapping = ({ tab, id }) => {
return {
@@ -254,6 +239,7 @@ const tabToFilterMapping = ({ tab, id }) => {
export default {
components: {
+ SocialMedia,
PostTeaser,
HcFollowButton,
HcCountTo,
@@ -292,17 +278,6 @@ export default {
user() {
return this.User ? this.User[0] : {}
},
- socialMediaLinks() {
- const { socialMedia = [] } = this.user
- return socialMedia.map((socialMedia) => {
- const { url } = socialMedia
- const matches = url.match(/^(?:https?:\/\/)?(?:[^@\n])?(?:www\.)?([^:/\n?]+)/g)
- const [domain] = matches || []
- const favicon = domain ? `${domain}/favicon.ico` : null
- const username = url.split('/').pop()
- return { url, username, favicon }
- })
- },
userName() {
const { name } = this.user || {}
return name || this.$t('profile.userAnonym')