From b524e73a6566ca4a6cfd9331457d2cb2958b3214 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Mon, 17 Dec 2018 01:53:21 +0300 Subject: [PATCH] Add local profile test --- test/unit/specs/boot/routes.spec.js | 3 +- .../specs/components/user_profile.spec.js | 109 +++++++++++++++++- 2 files changed, 107 insertions(+), 5 deletions(-) diff --git a/test/unit/specs/boot/routes.spec.js b/test/unit/specs/boot/routes.spec.js index 638b1860..9963555f 100644 --- a/test/unit/specs/boot/routes.spec.js +++ b/test/unit/specs/boot/routes.spec.js @@ -24,7 +24,6 @@ describe('routes', () => { const matchedComponents = router.getMatchedComponents() - console.log(matchedComponents[0].components.UserCardContent) - expect(matchedComponents[0].components.hasOwnProperty('UserProfile')).to.eql(true) + expect(matchedComponents[0].components.hasOwnProperty('UserCardContent')).to.eql(true) }) }) diff --git a/test/unit/specs/components/user_profile.spec.js b/test/unit/specs/components/user_profile.spec.js index b3497f30..04092716 100644 --- a/test/unit/specs/components/user_profile.spec.js +++ b/test/unit/specs/components/user_profile.spec.js @@ -10,7 +10,7 @@ const mutations = { clearTimeline: () => {} } -const store = new Vuex.Store({ +const externalProfileStore = new Vuex.Store({ mutations, state: { api: { @@ -97,11 +97,98 @@ const store = new Vuex.Store({ } }) +const localProfileStore = new Vuex.Store({ + mutations, + state: { + api: { + backendInteractor: backendInteractorService('') + }, + config: { + colors: '', + highlight: {} + }, + instance: { + hideUserStats: true + }, + statuses: { + timelines: { + user: { + statuses: [], + statusesObject: {}, + faves: [], + visibleStatuses: [], + visibleStatusesObject: {}, + newStatusCount: 0, + maxId: 0, + minVisibleId: 0, + loading: false, + followers: [], + friends: [], + viewing: 'statuses', + userId: 701, + flushMarker: 0 + } + } + }, + users: { + currentUser: { + credentials: '' + }, + usersObject: [ + { + background_image: null, + cover_photo: 'https://playvicious.social/system/accounts/headers/000/000/001/original/7dae4fc0e8330e83.jpg?1507329206', + created_at: 'Mon Dec 18 16:01:35 +0000 2017', + default_scope: 'public', + description: "Your favorite person's favorite person.", + description_html: "

Your favorite person's favorite person.

", + favourites_count: 0, + fields: [ + { + name: '✌🏾', + value: 'thetwelfth.house' + }, + { + name: '🚧', + value: 'code.playvicio.us' + }, + { + name: '❤️', + value: 'patreon.com/Are0h' + } + ], + followers_count: 2, + following: false, + follows_you: false, + friends_count: 0, + id: 701, + is_local: false, + locked: false, + name: 'Are0h', + name_html: 'Are0h', + no_rich_text: false, + profile_image_url: 'https://playvicious.social/system/accounts/avatars/000/000/001/original/33e9983bc2d96aeb.png?1520872572', + profile_image_url_https: 'https://playvicious.social/system/accounts/avatars/000/000/001/original/33e9983bc2d96aeb.png?1520872572', + profile_image_url_original: 'https://playvicious.social/system/accounts/avatars/000/000/001/original/33e9983bc2d96aeb.png?1520872572', + profile_image_url_profile_size: 'https://playvicious.social/system/accounts/avatars/000/000/001/original/33e9983bc2d96aeb.png?1520872572', + rights: { + delete_others_notice: false + }, + screen_name: 'Are0h', + statuses_count: 6727, + statusnet_blocking: false, + statusnet_profile_url: 'https://playvicious.social/users/Are0h' + } + ] + } + } +}) + describe('UserProfile', () => { - it('renders', () => { + it('renders external profile', () => { const wrapper = mount(UserProfile, { localVue, - store, + store: externalProfileStore, mocks: { $route: { params: { id: 701 }, @@ -113,4 +200,20 @@ describe('UserProfile', () => { expect(wrapper.find('.user-screen-name').text()).to.eql('@Are0h@playvicious.social') }) + + it('renders local profile', () => { + const wrapper = mount(UserProfile, { + localVue, + store: localProfileStore, + mocks: { + $route: { + params: { name: 'Are0h' }, + name: 'user-profile' + }, + $t: (msg) => msg + } + }) + + expect(wrapper.find('.user-screen-name').text()).to.eql('@Are0h') + }) })