User.spec.js 885 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { mount, createLocalVue } from '@vue/test-utils'
  2. import VueRouter from 'vue-router'
  3. import CoreuiVue from '@coreui/vue'
  4. import User from '@/views/users/User'
  5. import appRouter from '@/router'
  6. const localVue = createLocalVue()
  7. localVue.use(VueRouter)
  8. const router = appRouter
  9. router.push({path: '/users/1'})
  10. localVue.use(CoreuiVue)
  11. describe('User.vue', () => {
  12. let wrapper
  13. beforeEach(() => {
  14. wrapper = mount(User, {
  15. localVue,
  16. router
  17. })
  18. })
  19. it('has a name', () => {
  20. expect(User.name).toBe('User')
  21. })
  22. it('is Vue instance', () => {
  23. expect(wrapper.vm).toBeTruthy()
  24. })
  25. it('is User', () => {
  26. expect(wrapper.findComponent(User)).toBeTruthy()
  27. })
  28. it('should have methods', () => {
  29. expect(typeof User.methods.goBack).toEqual('function')
  30. })
  31. test('renders correctly', () => {
  32. expect(wrapper.element).toMatchSnapshot()
  33. })
  34. })