2018-12-14 19:16:44 -08:00
|
|
|
import { mount, createLocalVue } from '@vue/test-utils'
|
|
|
|
import Vuex from 'vuex'
|
|
|
|
import UserProfile from 'src/components/user_profile/user_profile.vue'
|
|
|
|
import backendInteractorService from 'src/services/backend_interactor_service/backend_interactor_service.js'
|
2018-12-30 17:57:22 -08:00
|
|
|
import { getters } from 'src/modules/users.js'
|
2018-12-14 19:16:44 -08:00
|
|
|
|
|
|
|
const localVue = createLocalVue()
|
|
|
|
localVue.use(Vuex)
|
|
|
|
|
|
|
|
const mutations = {
|
2018-12-28 11:39:54 -08:00
|
|
|
clearTimeline: () => {},
|
|
|
|
setError: () => {}
|
2018-12-14 19:16:44 -08:00
|
|
|
}
|
|
|
|
|
2019-03-10 17:17:49 -07:00
|
|
|
const actions = {
|
|
|
|
fetchUser: () => {},
|
|
|
|
fetchUserByScreenName: () => {}
|
|
|
|
}
|
|
|
|
|
2018-12-30 17:57:22 -08:00
|
|
|
const testGetters = {
|
2019-10-06 13:28:30 -07:00
|
|
|
findUser: state => getters.findUser(state.users),
|
|
|
|
mergedConfig: state => ({
|
|
|
|
colors: '',
|
|
|
|
highlight: {},
|
|
|
|
customTheme: {
|
|
|
|
colors: []
|
|
|
|
}
|
|
|
|
})
|
2018-12-30 17:57:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
const localUser = {
|
|
|
|
id: 100,
|
|
|
|
is_local: true,
|
|
|
|
screen_name: 'testUser'
|
|
|
|
}
|
|
|
|
|
|
|
|
const extUser = {
|
|
|
|
id: 100,
|
|
|
|
is_local: false,
|
|
|
|
screen_name: 'testUser@test.instance'
|
|
|
|
}
|
|
|
|
|
2018-12-16 14:53:21 -08:00
|
|
|
const externalProfileStore = new Vuex.Store({
|
2018-12-14 19:16:44 -08:00
|
|
|
mutations,
|
2019-03-10 17:17:49 -07:00
|
|
|
actions,
|
2018-12-30 17:57:22 -08:00
|
|
|
getters: testGetters,
|
2018-12-14 19:16:44 -08:00
|
|
|
state: {
|
|
|
|
api: {
|
2019-04-28 10:46:01 -07:00
|
|
|
fetchers: {},
|
2018-12-14 19:16:44 -08:00
|
|
|
backendInteractor: backendInteractorService('')
|
|
|
|
},
|
2018-12-16 15:45:40 -08:00
|
|
|
interface: {
|
|
|
|
browserSupport: ''
|
|
|
|
},
|
2018-12-14 19:16:44 -08:00
|
|
|
instance: {
|
|
|
|
hideUserStats: true
|
|
|
|
},
|
|
|
|
statuses: {
|
|
|
|
timelines: {
|
|
|
|
user: {
|
|
|
|
statuses: [],
|
|
|
|
statusesObject: {},
|
|
|
|
faves: [],
|
|
|
|
visibleStatuses: [],
|
|
|
|
visibleStatusesObject: {},
|
|
|
|
newStatusCount: 0,
|
|
|
|
maxId: 0,
|
|
|
|
minVisibleId: 0,
|
|
|
|
loading: false,
|
|
|
|
followers: [],
|
|
|
|
friends: [],
|
|
|
|
viewing: 'statuses',
|
2018-12-30 17:57:22 -08:00
|
|
|
userId: 100,
|
2018-12-14 19:16:44 -08:00
|
|
|
flushMarker: 0
|
2019-01-26 05:51:07 -08:00
|
|
|
},
|
|
|
|
media: {
|
|
|
|
statuses: [],
|
|
|
|
statusesObject: {},
|
|
|
|
faves: [],
|
|
|
|
visibleStatuses: [],
|
|
|
|
visibleStatusesObject: {},
|
|
|
|
newStatusCount: 0,
|
|
|
|
maxId: 0,
|
|
|
|
minVisibleId: 0,
|
|
|
|
loading: false,
|
|
|
|
followers: [],
|
|
|
|
friends: [],
|
|
|
|
viewing: 'statuses',
|
|
|
|
userId: 100,
|
|
|
|
flushMarker: 0
|
2018-12-14 19:16:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
users: {
|
|
|
|
currentUser: {
|
|
|
|
credentials: ''
|
|
|
|
},
|
2019-03-10 17:17:49 -07:00
|
|
|
usersObject: { 100: extUser },
|
2018-12-30 17:57:22 -08:00
|
|
|
users: [extUser]
|
2018-12-14 19:16:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-12-16 14:53:21 -08:00
|
|
|
const localProfileStore = new Vuex.Store({
|
|
|
|
mutations,
|
2019-03-10 17:17:49 -07:00
|
|
|
actions,
|
2018-12-30 17:57:22 -08:00
|
|
|
getters: testGetters,
|
2018-12-16 14:53:21 -08:00
|
|
|
state: {
|
|
|
|
api: {
|
2019-04-28 10:46:01 -07:00
|
|
|
fetchers: {},
|
2018-12-16 14:53:21 -08:00
|
|
|
backendInteractor: backendInteractorService('')
|
|
|
|
},
|
2018-12-16 15:45:40 -08:00
|
|
|
interface: {
|
|
|
|
browserSupport: ''
|
|
|
|
},
|
2018-12-16 14:53:21 -08:00
|
|
|
config: {
|
|
|
|
colors: '',
|
2018-12-16 15:45:40 -08:00
|
|
|
highlight: {},
|
|
|
|
customTheme: {
|
|
|
|
colors: []
|
|
|
|
}
|
2018-12-16 14:53:21 -08:00
|
|
|
},
|
|
|
|
instance: {
|
|
|
|
hideUserStats: true
|
|
|
|
},
|
|
|
|
statuses: {
|
|
|
|
timelines: {
|
|
|
|
user: {
|
|
|
|
statuses: [],
|
|
|
|
statusesObject: {},
|
|
|
|
faves: [],
|
|
|
|
visibleStatuses: [],
|
|
|
|
visibleStatusesObject: {},
|
|
|
|
newStatusCount: 0,
|
|
|
|
maxId: 0,
|
|
|
|
minVisibleId: 0,
|
|
|
|
loading: false,
|
|
|
|
followers: [],
|
|
|
|
friends: [],
|
2019-01-26 05:51:07 -08:00
|
|
|
viewing: 'statuses',
|
|
|
|
userId: 100,
|
|
|
|
flushMarker: 0
|
|
|
|
},
|
|
|
|
media: {
|
|
|
|
statuses: [],
|
|
|
|
statusesObject: {},
|
|
|
|
faves: [],
|
|
|
|
visibleStatuses: [],
|
|
|
|
visibleStatusesObject: {},
|
|
|
|
newStatusCount: 0,
|
|
|
|
maxId: 0,
|
|
|
|
minVisibleId: 0,
|
|
|
|
loading: false,
|
|
|
|
followers: [],
|
|
|
|
friends: [],
|
2018-12-16 14:53:21 -08:00
|
|
|
viewing: 'statuses',
|
2018-12-30 17:57:22 -08:00
|
|
|
userId: 100,
|
2018-12-16 14:53:21 -08:00
|
|
|
flushMarker: 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
users: {
|
|
|
|
currentUser: {
|
|
|
|
credentials: ''
|
|
|
|
},
|
2019-03-10 17:17:49 -07:00
|
|
|
usersObject: { 100: localUser, 'testuser': localUser },
|
2018-12-30 17:57:22 -08:00
|
|
|
users: [localUser]
|
2018-12-16 14:53:21 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-03-10 17:17:49 -07:00
|
|
|
describe('UserProfile', () => {
|
2018-12-16 14:53:21 -08:00
|
|
|
it('renders external profile', () => {
|
2018-12-14 19:16:44 -08:00
|
|
|
const wrapper = mount(UserProfile, {
|
|
|
|
localVue,
|
2018-12-16 14:53:21 -08:00
|
|
|
store: externalProfileStore,
|
2018-12-14 19:16:44 -08:00
|
|
|
mocks: {
|
|
|
|
$route: {
|
2018-12-30 17:57:22 -08:00
|
|
|
params: { id: 100 },
|
2018-12-14 19:16:44 -08:00
|
|
|
name: 'external-user-profile'
|
|
|
|
},
|
|
|
|
$t: (msg) => msg
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-12-30 17:57:22 -08:00
|
|
|
expect(wrapper.find('.user-screen-name').text()).to.eql('@testUser@test.instance')
|
2018-12-14 19:16:44 -08:00
|
|
|
})
|
2018-12-16 14:53:21 -08:00
|
|
|
|
|
|
|
it('renders local profile', () => {
|
|
|
|
const wrapper = mount(UserProfile, {
|
|
|
|
localVue,
|
|
|
|
store: localProfileStore,
|
|
|
|
mocks: {
|
|
|
|
$route: {
|
2018-12-30 17:57:22 -08:00
|
|
|
params: { name: 'testUser' },
|
2018-12-16 14:53:21 -08:00
|
|
|
name: 'user-profile'
|
|
|
|
},
|
|
|
|
$t: (msg) => msg
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-12-30 17:57:22 -08:00
|
|
|
expect(wrapper.find('.user-screen-name').text()).to.eql('@testUser')
|
2018-12-16 14:53:21 -08:00
|
|
|
})
|
2018-12-14 19:16:44 -08:00
|
|
|
})
|