logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

user_profile.spec.js (4674B)


  1. import { mount } from '@vue/test-utils'
  2. import { createStore } from 'vuex'
  3. import UserProfile from 'src/components/user_profile/user_profile.vue'
  4. import backendInteractorService from 'src/services/backend_interactor_service/backend_interactor_service.js'
  5. import { getters } from 'src/modules/users.js'
  6. const mutations = {
  7. clearTimeline: () => {}
  8. }
  9. const actions = {
  10. fetchUser: () => {},
  11. fetchUserByScreenName: () => {}
  12. }
  13. const testGetters = {
  14. findUser: state => getters.findUser(state.users),
  15. findUserByName: state => getters.findUserByName(state.users),
  16. relationship: state => getters.relationship(state.users),
  17. mergedConfig: state => ({
  18. colors: '',
  19. highlight: {},
  20. customTheme: {
  21. colors: []
  22. }
  23. })
  24. }
  25. const localUser = {
  26. id: 100,
  27. is_local: true,
  28. screen_name: 'testUser',
  29. screen_name_ui: 'testUser'
  30. }
  31. const extUser = {
  32. id: 100,
  33. is_local: false,
  34. screen_name: 'testUser@test.instance',
  35. screen_name_ui: 'testUser@test.instance'
  36. }
  37. const externalProfileStore = createStore({
  38. mutations,
  39. actions,
  40. getters: testGetters,
  41. state: {
  42. api: {
  43. fetchers: {},
  44. backendInteractor: backendInteractorService('')
  45. },
  46. interface: {
  47. browserSupport: ''
  48. },
  49. instance: {
  50. hideUserStats: true
  51. },
  52. statuses: {
  53. timelines: {
  54. user: {
  55. statuses: [],
  56. statusesObject: {},
  57. faves: [],
  58. visibleStatuses: [],
  59. visibleStatusesObject: {},
  60. newStatusCount: 0,
  61. maxId: 0,
  62. minVisibleId: 0,
  63. loading: false,
  64. followers: [],
  65. friends: [],
  66. viewing: 'statuses',
  67. userId: 100,
  68. flushMarker: 0
  69. },
  70. media: {
  71. statuses: [],
  72. statusesObject: {},
  73. faves: [],
  74. visibleStatuses: [],
  75. visibleStatusesObject: {},
  76. newStatusCount: 0,
  77. maxId: 0,
  78. minVisibleId: 0,
  79. loading: false,
  80. followers: [],
  81. friends: [],
  82. viewing: 'statuses',
  83. userId: 100,
  84. flushMarker: 0
  85. }
  86. }
  87. },
  88. users: {
  89. currentUser: {
  90. credentials: ''
  91. },
  92. usersObject: { 100: extUser },
  93. usersByNameObject: {},
  94. users: [extUser],
  95. relationships: {}
  96. }
  97. }
  98. })
  99. const localProfileStore = createStore({
  100. mutations,
  101. actions,
  102. getters: testGetters,
  103. state: {
  104. api: {
  105. fetchers: {},
  106. backendInteractor: backendInteractorService('')
  107. },
  108. interface: {
  109. browserSupport: ''
  110. },
  111. config: {
  112. colors: '',
  113. highlight: {},
  114. customTheme: {
  115. colors: []
  116. }
  117. },
  118. instance: {
  119. hideUserStats: true
  120. },
  121. statuses: {
  122. timelines: {
  123. user: {
  124. statuses: [],
  125. statusesObject: {},
  126. faves: [],
  127. visibleStatuses: [],
  128. visibleStatusesObject: {},
  129. newStatusCount: 0,
  130. maxId: 0,
  131. minVisibleId: 0,
  132. loading: false,
  133. followers: [],
  134. friends: [],
  135. viewing: 'statuses',
  136. userId: 100,
  137. flushMarker: 0
  138. },
  139. media: {
  140. statuses: [],
  141. statusesObject: {},
  142. faves: [],
  143. visibleStatuses: [],
  144. visibleStatusesObject: {},
  145. newStatusCount: 0,
  146. maxId: 0,
  147. minVisibleId: 0,
  148. loading: false,
  149. followers: [],
  150. friends: [],
  151. viewing: 'statuses',
  152. userId: 100,
  153. flushMarker: 0
  154. }
  155. }
  156. },
  157. users: {
  158. currentUser: {
  159. credentials: ''
  160. },
  161. usersObject: { 100: localUser },
  162. usersByNameObject: { testuser: localUser },
  163. users: [localUser],
  164. relationships: {}
  165. }
  166. }
  167. })
  168. // https://github.com/vuejs/test-utils/issues/1382
  169. describe.skip('UserProfile', () => {
  170. it('renders external profile', () => {
  171. const wrapper = mount(UserProfile, {
  172. global: {
  173. plugins: [externalProfileStore],
  174. mocks: {
  175. $route: {
  176. params: { id: 100 },
  177. name: 'external-user-profile'
  178. },
  179. $t: (msg) => msg
  180. }
  181. }
  182. })
  183. expect(wrapper.find('.user-screen-name').text()).to.eql('@testUser@test.instance')
  184. })
  185. it('renders local profile', () => {
  186. const wrapper = mount(UserProfile, {
  187. global: {
  188. plugins: [localProfileStore],
  189. mocks: {
  190. $route: {
  191. params: { name: 'testUser' },
  192. name: 'user-profile'
  193. },
  194. $t: (msg) => msg
  195. }
  196. }
  197. })
  198. expect(wrapper.find('.user-screen-name').text()).to.eql('@testUser')
  199. })
  200. })