Dashboard.spec.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import Vue from 'vue'
  2. import { shallowMount } from '@vue/test-utils'
  3. import CoreuiVue from '@coreui/vue'
  4. import Dashboard from '@/views/Dashboard'
  5. Vue.use(CoreuiVue)
  6. describe('Dashboard.vue', () => {
  7. it('has a name', () => {
  8. expect(Dashboard.name).toBe('Dashboard')
  9. })
  10. it('has a created hook', () => {
  11. expect(typeof Dashboard.data).toMatch('function')
  12. })
  13. it('sets the correct default data', () => {
  14. expect(typeof Dashboard.data).toMatch('function')
  15. const defaultData = Dashboard.data()
  16. expect(defaultData.selected).toMatch('Month')
  17. })
  18. it('is Vue instance', () => {
  19. const wrapper = shallowMount(Dashboard)
  20. expect(wrapper.vm).toBeTruthy()
  21. })
  22. it('is Dashboard', () => {
  23. const wrapper = shallowMount(Dashboard)
  24. expect(wrapper.findComponent(Dashboard)).toBeTruthy()
  25. })
  26. it('should render correct content', () => {
  27. const wrapper = shallowMount(Dashboard)
  28. expect(wrapper.find('#traffic').text()).toMatch('Traffic')
  29. })
  30. test('renders correctly', () => {
  31. const wrapper = shallowMount(Dashboard)
  32. expect(wrapper.element).toMatchSnapshot()
  33. })
  34. })