test: restore and fix unit tests
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'
|
||||
import VueRouter from 'vue-router'
|
||||
import CoreuiVue from '@coreui/vue'
|
||||
import User from '@/views/users/User'
|
||||
|
||||
const localVue = createLocalVue()
|
||||
localVue.use(VueRouter)
|
||||
const router = new VueRouter()
|
||||
|
||||
localVue.use(CoreuiVue)
|
||||
|
||||
describe('User.vue', () => {
|
||||
it('has a name', () => {
|
||||
expect(User.name).toMatch('User')
|
||||
})
|
||||
it('is Vue instance', () => {
|
||||
const wrapper = shallowMount(User, {
|
||||
localVue,
|
||||
router
|
||||
})
|
||||
expect(wrapper.isVueInstance()).toBe(true)
|
||||
})
|
||||
it('is User', () => {
|
||||
const wrapper = shallowMount(User, {
|
||||
localVue,
|
||||
router
|
||||
})
|
||||
expect(wrapper.is(User)).toBe(true)
|
||||
})
|
||||
it('should have methods', () => {
|
||||
const wrapper = shallowMount(User,{
|
||||
localVue,
|
||||
router
|
||||
})
|
||||
|
||||
expect(typeof User.methods.goBack ).toEqual('function')
|
||||
expect(wrapper.vm.goBack()).toBeUndefined()
|
||||
})
|
||||
test('renders correctly', () => {
|
||||
const wrapper = shallowMount(User, {
|
||||
localVue,
|
||||
router
|
||||
})
|
||||
expect(wrapper.element).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,56 @@
|
||||
import { createLocalVue, shallowMount, mount } from '@vue/test-utils'
|
||||
import CoreuiVue from '@coreui/vue'
|
||||
import Users from '@/views/users/Users'
|
||||
import VueRouter from 'vue-router';
|
||||
|
||||
const localVue = createLocalVue()
|
||||
localVue.use(VueRouter)
|
||||
const router = new VueRouter()
|
||||
|
||||
localVue.use(CoreuiVue)
|
||||
|
||||
describe('Users.vue', () => {
|
||||
it('has a name', () => {
|
||||
expect(Users.name).toMatch('Users')
|
||||
})
|
||||
it('has a created hook', () => {
|
||||
expect(typeof Users.data).toMatch('function')
|
||||
})
|
||||
it('sets the correct default data', () => {
|
||||
expect(typeof Users.data).toMatch('function')
|
||||
const defaultData = Users.data()
|
||||
expect(defaultData.currentPage).toBe(1)
|
||||
})
|
||||
it('is Vue instance', () => {
|
||||
const wrapper = shallowMount(Users,{
|
||||
localVue,
|
||||
router
|
||||
})
|
||||
expect(wrapper.isVueInstance()).toBe(true)
|
||||
})
|
||||
it('is Users', () => {
|
||||
const wrapper = shallowMount(Users,{
|
||||
localVue,
|
||||
router
|
||||
})
|
||||
expect(wrapper.is(Users)).toBe(true)
|
||||
})
|
||||
test('renders correctly', () => {
|
||||
const wrapper = shallowMount(Users, {
|
||||
localVue,
|
||||
router
|
||||
})
|
||||
expect(wrapper.element).toMatchSnapshot()
|
||||
})
|
||||
it('should have methods', () => {
|
||||
const wrapper = shallowMount(Users,{
|
||||
localVue,
|
||||
router
|
||||
})
|
||||
|
||||
expect(typeof Users.methods.userLink ).toEqual('function')
|
||||
expect(Users.methods.userLink(42)).toBe('users/42')
|
||||
expect(typeof Users.methods.rowClicked ).toEqual('function')
|
||||
expect(wrapper.vm.rowClicked({id:42})).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,57 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`User.vue renders correctly 1`] = `
|
||||
<crow-stub>
|
||||
<ccol-stub
|
||||
col="12"
|
||||
lg="6"
|
||||
tag="div"
|
||||
>
|
||||
<ccard-stub
|
||||
subtitletag="h6"
|
||||
titletag="h4"
|
||||
>
|
||||
<ccardheader-stub
|
||||
subtitletag="h6"
|
||||
titletag="h4"
|
||||
>
|
||||
|
||||
User id:
|
||||
|
||||
</ccardheader-stub>
|
||||
|
||||
<ccardbody-stub
|
||||
subtitletag="h6"
|
||||
titletag="h4"
|
||||
>
|
||||
<ctable-stub
|
||||
defaultsorter="[object Object]"
|
||||
fields="[object Object],[object Object]"
|
||||
fixed="true"
|
||||
items="[object Object]"
|
||||
perpage="10"
|
||||
small="true"
|
||||
striped="true"
|
||||
/>
|
||||
</ccardbody-stub>
|
||||
|
||||
<ccardfooter-stub
|
||||
subtitletag="h6"
|
||||
titletag="h4"
|
||||
>
|
||||
<cbutton-stub
|
||||
activeclass="c-active"
|
||||
event="click"
|
||||
exactactiveclass="c-active"
|
||||
routertag="a"
|
||||
target="_self"
|
||||
type="button"
|
||||
variant="primary"
|
||||
>
|
||||
Back
|
||||
</cbutton-stub>
|
||||
</ccardfooter-stub>
|
||||
</ccard-stub>
|
||||
</ccol-stub>
|
||||
</crow-stub>
|
||||
`;
|
||||
@@ -0,0 +1,30 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Users.vue renders correctly 1`] = `
|
||||
<crow-stub>
|
||||
<ccol-stub
|
||||
col="12"
|
||||
tag="div"
|
||||
xl="8"
|
||||
>
|
||||
<ccard-stub
|
||||
bodywrapper="true"
|
||||
headerhtml="users"
|
||||
name="slide"
|
||||
subtitletag="h6"
|
||||
titletag="h4"
|
||||
>
|
||||
<ctable-stub
|
||||
current-page="1"
|
||||
defaultsorter="[object Object]"
|
||||
fields="[object Object],[object Object],[object Object],[object Object],[object Object]"
|
||||
hover="true"
|
||||
items="[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]"
|
||||
pagination="[object Object]"
|
||||
perpage="5"
|
||||
striped="true"
|
||||
/>
|
||||
</ccard-stub>
|
||||
</ccol-stub>
|
||||
</crow-stub>
|
||||
`;
|
||||
Reference in New Issue
Block a user