diff --git a/backend/src/resolvers/user_management.spec.js b/backend/src/resolvers/user_management.spec.js index 1c21adac1..a6ef48ee5 100644 --- a/backend/src/resolvers/user_management.spec.js +++ b/backend/src/resolvers/user_management.spec.js @@ -309,3 +309,30 @@ describe('change password', () => { }) }) }) + +describe('addSocialMedia', () => { + let client + let headers + const mutation = ` + mutation($url: String!) { + addSocialMedia(url: $url) + } + ` + + describe('authenticated', () => { + beforeEach(async () => { + headers = await login({ email: 'test@example.org', password: '1234' }) + client = new GraphQLClient(host, { headers }) + }) + + it('rejects empty string', async () => { + const variables = { url: '' } + await expect(client.request(mutation, variables)).rejects.toThrow('Input is not a URL') + }) + + it('validates URLs', async () => { + const variables = { url: 'not-a-url' } + await expect(client.request(mutation, variables)).rejects.toThrow('Input is not a URL') + }) + }) +}) diff --git a/webapp/pages/settings/my-social-media.spec.js b/webapp/pages/settings/my-social-media.spec.js new file mode 100644 index 000000000..b3e198a6f --- /dev/null +++ b/webapp/pages/settings/my-social-media.spec.js @@ -0,0 +1,60 @@ +import { shallowMount, mount, createLocalVue } from '@vue/test-utils' +import MySocialMedia from './my-social-media.vue' +import Vue from 'vue' +import Vuex from 'vuex' +import Styleguide from '@human-connection/styleguide' + +const localVue = createLocalVue() + +localVue.use(Vuex) +localVue.use(Styleguide) + +describe('my-social-media.vue', () => { + let wrapper + let Wrapper + let store + let mocks + let getters + + beforeEach(() => { + mocks = { + $t: jest.fn() + } + getters = { + 'auth/user': () => { + return {} + } + } + }) + + describe('shallowMount', () => { + const Wrapper = () => { + store = new Vuex.Store({ + getters + }) + return shallowMount(MySocialMedia, { store, mocks, localVue }) + } + + it('renders', () => { + wrapper = Wrapper() + expect(wrapper.contains('div')).toBe(true) + }) + + describe('given currentUser has social media accounts', () => { + beforeEach(() => { + getters = { + 'auth/user': () => { + return { + socialMedia: [''] + } + } + } + }) + + it('renders', () => { + wrapper = Wrapper() + expect(wrapper.contains('div')).toBe(true) + }) + }) + }) +}) diff --git a/webapp/pages/settings/my-social-media.vue b/webapp/pages/settings/my-social-media.vue index 6bccd9949..201c0759f 100644 --- a/webapp/pages/settings/my-social-media.vue +++ b/webapp/pages/settings/my-social-media.vue @@ -1,5 +1,25 @@