refactor: refactoring template
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// import Vue from 'vue'
|
||||
import CoreuiVueModule from '@coreui/vue'
|
||||
// Vue.use(CoreuiVueModule)
|
||||
|
||||
test("Should register all components when installed", () => {
|
||||
|
||||
const component = jest.fn();
|
||||
const Vue = { component };
|
||||
|
||||
CoreuiVueModule.install(Vue);
|
||||
|
||||
// Test if a particular component was registered
|
||||
expect(component).toBeCalledWith("Aside", expect.any(Object));
|
||||
expect(component).toBeCalledWith("AsideToggler", expect.any(Object));
|
||||
expect(component).toBeCalledWith("Breadcrumb", expect.any(Object));
|
||||
expect(component).toBeCalledWith("Callout", expect.any(Object));
|
||||
expect(component).toBeCalledWith("Footer", expect.any(Object));
|
||||
expect(component).toBeCalledWith("Header", expect.any(Object));
|
||||
expect(component).toBeCalledWith("HeaderDropdown", expect.any(Object));
|
||||
expect(component).toBeCalledWith("Sidebar", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarFooter", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarForm", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarHeader", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarMinimizer", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarNav", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarNavDivider", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarNavItem", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarNavDropdown", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarNavLabel", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarNavLink", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarNavTitle", expect.any(Object));
|
||||
expect(component).toBeCalledWith("SidebarToggler", expect.any(Object));
|
||||
expect(component).toBeCalledWith("Switch", expect.any(Object));
|
||||
|
||||
// Test how many times component got registered
|
||||
// const totalOfComponents = 21;
|
||||
// expect(component).toHaveBeenCalledTimes(totalOfComponents);
|
||||
});
|
||||
@@ -1,37 +0,0 @@
|
||||
import Vue from 'vue'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BootstrapVue from 'bootstrap-vue'
|
||||
import Component from '@/views/widgets/Widget01'
|
||||
|
||||
Vue.use(BootstrapVue)
|
||||
|
||||
const ComponentName = 'Widget01'
|
||||
const wrapper = shallowMount(Component)
|
||||
|
||||
describe(ComponentName + '.vue', () => {
|
||||
it('has a name', () => {
|
||||
expect(Component.name).toMatch(ComponentName)
|
||||
})
|
||||
it('has a created hook', () => {
|
||||
expect(typeof Component.data).toMatch('function')
|
||||
})
|
||||
it('is Vue instance', () => {
|
||||
expect(wrapper.isVueInstance()).toBe(true)
|
||||
})
|
||||
it('correctly sets default props and data when created', () => {
|
||||
const vm = new Vue(Component).$mount()
|
||||
expect(vm.backgroundColor).toBe('')
|
||||
expect(vm.styleClasses).toBe('')
|
||||
expect(vm.header).toBe('header:string')
|
||||
expect(vm.text).toBe('text:string')
|
||||
expect(vm.variant).toBe('')
|
||||
expect(vm.footer).toBe('footer:string')
|
||||
expect(vm.value == 25).toBe(true)
|
||||
})
|
||||
it('correctly sets variant when background is not white', () => {
|
||||
const Constructor = Vue.extend(Component)
|
||||
const vm = new Constructor({ propsData: {variant : 'background-success'}}).$mount()
|
||||
expect(vm.backgroundColor).toBe('success')
|
||||
expect(vm.styleClasses).toBe('text-white bg-success')
|
||||
})
|
||||
})
|
||||
@@ -1,26 +0,0 @@
|
||||
import Vue from 'vue'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BootstrapVue from 'bootstrap-vue'
|
||||
import Component from '@/views/widgets/Widget02'
|
||||
|
||||
Vue.use(BootstrapVue)
|
||||
|
||||
const ComponentName = 'Widget02'
|
||||
const wrapper = shallowMount(Component)
|
||||
|
||||
describe(ComponentName + '.vue', () => {
|
||||
it('has a name', () => {
|
||||
expect(Component.name).toMatch(ComponentName)
|
||||
})
|
||||
it('is Vue instance', () => {
|
||||
expect(wrapper.isVueInstance()).toBe(true)
|
||||
})
|
||||
it('correctly sets default props when created', () => {
|
||||
const vm = new Vue(Component).$mount()
|
||||
expect(vm.header).toBe('header:string')
|
||||
expect(vm.text).toBe('text:string')
|
||||
expect(vm.link).toBe('#')
|
||||
expect(vm.iconClasses).toBe('fa fa-cogs bg-primary')
|
||||
expect(vm.showLink).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
import Vue from 'vue'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BootstrapVue from 'bootstrap-vue'
|
||||
import Component from '@/views/widgets/Widget03'
|
||||
|
||||
Vue.use(BootstrapVue)
|
||||
|
||||
const ComponentName = 'Widget03'
|
||||
const wrapper = shallowMount(Component)
|
||||
|
||||
describe(ComponentName + '.vue', () => {
|
||||
it('has a name', () => {
|
||||
expect(Component.name).toMatch(ComponentName)
|
||||
})
|
||||
it('is Vue instance', () => {
|
||||
expect(wrapper.isVueInstance()).toBe(true)
|
||||
})
|
||||
it('correctly sets default props when created', () => {
|
||||
const vm = new Vue(Component).$mount()
|
||||
expect(vm.header).toBe('header:string')
|
||||
expect(vm.text).toBe('text:string')
|
||||
expect(vm.iconClasses).toBe('fa fa-cogs bg-primary')
|
||||
})
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
import Vue from 'vue'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BootstrapVue from 'bootstrap-vue'
|
||||
import Component from '@/views/widgets/Widget04'
|
||||
|
||||
Vue.use(BootstrapVue)
|
||||
|
||||
const ComponentName = 'Widget04'
|
||||
const wrapper = shallowMount(Component)
|
||||
|
||||
describe(ComponentName + '.vue', () => {
|
||||
it('has a name', () => {
|
||||
expect(Component.name).toMatch(ComponentName)
|
||||
})
|
||||
it('is Vue instance', () => {
|
||||
expect(wrapper.isVueInstance()).toBe(true)
|
||||
})
|
||||
it('correctly sets default props and data when created', () => {
|
||||
expect(wrapper.props().rightHeader).toBe('rightHeader:string')
|
||||
expect(wrapper.props().rightFooter).toBe('rightFooter:string')
|
||||
expect(wrapper.props().leftHeader).toBe('leftHeader:string')
|
||||
expect(wrapper.props().leftFooter).toBe('leftFooter:string')
|
||||
})
|
||||
})
|
||||
@@ -1,36 +0,0 @@
|
||||
import Vue from 'vue'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BootstrapVue from 'bootstrap-vue'
|
||||
import Component from '@/views/widgets/Widget05'
|
||||
|
||||
Vue.use(BootstrapVue)
|
||||
|
||||
const ComponentName = 'Widget05'
|
||||
const wrapper = shallowMount(Component)
|
||||
|
||||
describe(ComponentName + '.vue', () => {
|
||||
it('has a name', () => {
|
||||
expect(Component.name).toMatch(ComponentName)
|
||||
})
|
||||
it('is Vue instance', () => {
|
||||
expect(wrapper.isVueInstance()).toBe(true)
|
||||
})
|
||||
it('has a created hook', () => {
|
||||
expect(typeof Component.data).toMatch('function')
|
||||
})
|
||||
it('correctly sets default props and data when created', () => {
|
||||
const vm = new Vue(Component).$mount()
|
||||
expect(vm.backgroundColor).toBe('')
|
||||
expect(vm.styleClasses).toBe('')
|
||||
expect(vm.header).toBe('header:string')
|
||||
expect(vm.text).toBe('text:string')
|
||||
expect(vm.variant).toBe('')
|
||||
expect(vm.value == 25).toBe(true)
|
||||
})
|
||||
it('correctly sets variant when background is not white', () => {
|
||||
const Constructor = Vue.extend(Component)
|
||||
const vm = new Constructor({ propsData: {variant : 'background-success'}}).$mount()
|
||||
expect(vm.backgroundColor).toBe('success')
|
||||
expect(vm.styleClasses).toBe('text-white bg-success')
|
||||
})
|
||||
})
|
||||
@@ -1,23 +0,0 @@
|
||||
import Vue from 'vue'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BootstrapVue from 'bootstrap-vue'
|
||||
import Component from '@/views/widgets/Widget06'
|
||||
|
||||
Vue.use(BootstrapVue)
|
||||
|
||||
const ComponentName = 'Widget06'
|
||||
const wrapper = shallowMount(Component)
|
||||
|
||||
describe(ComponentName + '.vue', () => {
|
||||
it('has a name', () => {
|
||||
expect(Component.name).toMatch(ComponentName)
|
||||
})
|
||||
it('is Vue instance', () => {
|
||||
expect(wrapper.isVueInstance()).toBe(true)
|
||||
})
|
||||
it('correctly sets default props and data when created', () => {
|
||||
expect(wrapper.props().cardClasses).toBe('')
|
||||
expect(wrapper.props().header).toBe('header:string')
|
||||
expect(wrapper.props().text).toBe('text:string')
|
||||
})
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
import Vue from 'vue'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BootstrapVue from 'bootstrap-vue'
|
||||
import Component from '@/views/widgets/Widget07'
|
||||
|
||||
Vue.use(BootstrapVue)
|
||||
|
||||
const ComponentName = 'Widget07'
|
||||
const wrapper = shallowMount(Component)
|
||||
|
||||
describe(ComponentName + '.vue', () => {
|
||||
it('has a name', () => {
|
||||
expect(Component.name).toMatch(ComponentName)
|
||||
})
|
||||
it('is Vue instance', () => {
|
||||
expect(wrapper.isVueInstance()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
import Vue from 'vue'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import BootstrapVue from 'bootstrap-vue'
|
||||
import Component from '@/views/widgets/Widget08'
|
||||
|
||||
Vue.use(BootstrapVue)
|
||||
|
||||
const ComponentName = 'Widget08'
|
||||
const wrapper = shallowMount(Component)
|
||||
|
||||
describe(ComponentName + '.vue', () => {
|
||||
it('has a name', () => {
|
||||
expect(Component.name).toMatch(ComponentName)
|
||||
})
|
||||
it('is Vue instance', () => {
|
||||
expect(wrapper.isVueInstance()).toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user