Skip to content

Commit 704e04f

Browse files
committed
test: restore and fix unit tests
1 parent f9a4949 commit 704e04f

File tree

89 files changed

+55790
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+55790
-6
lines changed

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
22
presets: [
3-
['@vue/app']
3+
[ "@vue/app", { useBuiltIns: "entry" } ]
44
]
55
}

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ module.exports = {
88
transform: {
99
'^.+\\.vue$': 'vue-jest',
1010
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
11-
'^.+\\.jsx?$': 'babel-jest'
11+
'^.+\\.jsx?$': '<rootDir>/node_modules/babel-jest'
1212
},
13+
transformIgnorePatterns: ["/node_modules/(?!@coreui/icons)"],
1314
moduleNameMapper: {
1415
'^@/(.*)$': '<rootDir>/src/$1'
1516
},

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@coreui/coreui": "next",
1818
"@coreui/coreui-plugin-chartjs-custom-tooltips": "^1.3.1",
1919
"@coreui/coreui-vue-chartjs": "../coreui-vue-chartjs",
20-
"@coreui/icons": "coreui/coreui-icons#v1-alpha",
20+
"@coreui/icons": "github:coreui/coreui-icons#v1-alpha",
2121
"@coreui/vue": "../coreui-vue",
2222
"vue": "^2.6.10",
2323
"vue-router": "^3.0.7"
@@ -28,12 +28,12 @@
2828
"@vue/cli-plugin-eslint": "^3.9.2",
2929
"@vue/cli-plugin-unit-jest": "^3.9.0",
3030
"@vue/cli-service": "^3.9.2",
31-
"@vue/test-utils": "^1.0.0-beta.25",
32-
"babel-core": "^6.26.3",
31+
"@vue/test-utils": "^1.0.0-beta.29",
32+
"babel-core": "^7.0.0-bridge.0",
33+
"babel-jest": "23.6.0",
3334
"babel-plugin-dynamic-import-node": "^2.3.0",
3435
"babel-plugin-module-resolver": "^3.2.0",
3536
"babel-preset-vue-app": "^2.0.0",
36-
"babel-jest": "23.6.0",
3737
"growl": "^1.10.5",
3838
"https-proxy-agent": "^2.2.2",
3939
"node-sass": "^4.12.0",

tests/unit/.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
env: {
3+
jest: true
4+
},
5+
rules: {
6+
'import/no-extraneous-dependencies': 'off'
7+
}
8+
}

tests/unit/App.spec.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { shallowMount, createLocalVue } from '@vue/test-utils'
2+
import VueRouter from 'vue-router'
3+
import CoreuiVue from '@coreui/vue'
4+
import App from '@/App'
5+
6+
const localVue = createLocalVue()
7+
localVue.use(VueRouter)
8+
const router = new VueRouter()
9+
10+
11+
localVue.use(CoreuiVue)
12+
13+
describe('App.vue', () => {
14+
it('has a name', () => {
15+
expect(App.name).toMatch('app')
16+
})
17+
it('is Vue instance', () => {
18+
const wrapper = shallowMount(App, {
19+
localVue,
20+
router
21+
})
22+
expect(wrapper.isVueInstance()).toBe(true)
23+
})
24+
it('is App', () => {
25+
const wrapper = shallowMount(App, {
26+
localVue,
27+
router
28+
})
29+
expect(wrapper.is(App)).toBe(true)
30+
})
31+
})
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import CoreuiVue from '@coreui/vue'
2+
import { shallowMount, createLocalVue } from '@vue/test-utils';
3+
import VueRouter from 'vue-router'
4+
import DefaultContainer from '@/containers/DefaultContainer'
5+
6+
const localVue = createLocalVue()
7+
localVue.use(VueRouter)
8+
const router = new VueRouter()
9+
10+
localVue.use(CoreuiVue)
11+
12+
describe('DefaultContainer.vue', () => {
13+
it('has a name', () => {
14+
expect(DefaultContainer.name).toMatch('full')
15+
})
16+
test('renders correctly', () => {
17+
const wrapper = shallowMount(DefaultContainer, {
18+
localVue,
19+
router
20+
})
21+
expect(wrapper.element).toMatchSnapshot()
22+
})
23+
it('is Vue instance', () => {
24+
const wrapper = shallowMount(DefaultContainer, {
25+
localVue,
26+
router
27+
})
28+
expect(wrapper.isVueInstance()).toBe(true)
29+
})
30+
})
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Vue from 'vue'
2+
import CoreuiVue from '@coreui/vue'
3+
import DefaultHeaderDropdownAccnt from '@/containers/DefaultHeaderDropdownAccnt'
4+
import { shallowMount } from '@vue/test-utils';
5+
6+
Vue.use(CoreuiVue)
7+
8+
describe('DefaultHeaderDropdownAccnt.vue', () => {
9+
it('has a name', () => {
10+
expect(DefaultHeaderDropdownAccnt.name).toMatch('DefaultHeaderDropdownAccnt')
11+
})
12+
it('has a created hook', () => {
13+
expect(typeof DefaultHeaderDropdownAccnt.data).toMatch('function')
14+
})
15+
it('sets the correct default data', () => {
16+
expect(typeof DefaultHeaderDropdownAccnt.data).toMatch('function')
17+
const defaultData = DefaultHeaderDropdownAccnt.data()
18+
expect(defaultData.itemsCount).toBe(42)
19+
})
20+
test('renders correctly', () => {
21+
const wrapper = shallowMount(DefaultHeaderDropdownAccnt)
22+
expect(wrapper.element).toMatchSnapshot()
23+
})
24+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Vue from 'vue'
2+
import CoreuiVue from '@coreui/vue'
3+
import TheFooter from '@/containers/TheFooter'
4+
import { shallowMount } from '@vue/test-utils';
5+
6+
Vue.use(CoreuiVue)
7+
8+
describe('TheFooter.vue', () => {
9+
10+
test('renders correctly', () => {
11+
const wrapper = shallowMount(TheFooter)
12+
expect(wrapper.element).toMatchSnapshot()
13+
})
14+
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Vue from 'vue'
2+
import CoreuiVue from '@coreui/vue'
3+
import TheHeader from '@/containers/TheHeader'
4+
import { shallowMount } from '@vue/test-utils';
5+
6+
Vue.use(CoreuiVue)
7+
8+
describe('TheHeader.vue', () => {
9+
test('renders correctly', () => {
10+
const wrapper = shallowMount(TheHeader)
11+
expect(wrapper.element).toMatchSnapshot()
12+
})
13+
})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Vue from 'vue'
2+
import { shallowMount } from '@vue/test-utils';
3+
import CoreuiVue from '@coreui/vue'
4+
import TheSidebar from '@/containers/TheSidebar'
5+
6+
Vue.use(CoreuiVue)
7+
8+
describe('TheSidebar.vue', () => {
9+
it('has a name', () => {
10+
expect(TheSidebar.name).toMatch('TheSidebar')
11+
})
12+
test('renders correctly', () => {
13+
const wrapper = shallowMount(TheSidebar)
14+
expect(wrapper.element).toMatchSnapshot()
15+
})
16+
})

0 commit comments

Comments
 (0)