Skip to content

Commit 45cb508

Browse files
committed
first test
1 parent 8e2499c commit 45cb508

File tree

6 files changed

+1161
-46
lines changed

6 files changed

+1161
-46
lines changed

jest.config.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
moduleFileExtensions: [
3+
'js',
4+
'jsx',
5+
'json',
6+
'vue'
7+
],
8+
transform: {
9+
'^.+\\.vue$': 'vue-jest',
10+
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
11+
'^.+\\.jsx?$': 'babel-jest'
12+
},
13+
moduleNameMapper: {
14+
'^@/(.*)$': '<rootDir>/src/$1'
15+
},
16+
snapshotSerializers: [
17+
'jest-serializer-vue'
18+
],
19+
testMatch: [
20+
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)|**/spec.(js|jsx|ts|tsx)'
21+
],
22+
testURL: 'http://localhost/'
23+
}

package.json

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
{
22
"name": "vue-cion-design-system",
33
"version": "1.0.0",
4-
"author": "visualjerk",
54
"private": true,
6-
"main": "./dist/system.umd.min.js",
7-
"files": [
8-
"dist/*",
9-
"src/*",
10-
"public/*",
11-
"*.json",
12-
"*.js"
13-
],
14-
"license": "MIT",
155
"scripts": {
6+
"serve": "http-server ./docs -o -s",
7+
"build": "yarn theo && vue-cli-service build",
8+
"lint": "vue-cli-service lint",
169
"dev": "npm-run-all --parallel theo:onchange theo servedev",
1710
"servedev": "vue-cli-service serve --open",
18-
"build": "yarn theo && vue-cli-service build",
1911
"build:lib": "yarn theo && BUILD=library vue-cli-service build --target lib --name system ./src/library.js",
20-
"serve": "http-server ./docs -o -s",
21-
"lint": "vue-cli-service lint",
2212
"theo": "theo ./src/system/tokens/tokens.yml --transform web --format map.scss,scss,raw.json,json --dest ./src/system/tokens/generated",
23-
"theo:onchange": "onchange \"./src/system/tokens/*.yml\" -- npm run theo"
13+
"theo:onchange": "onchange \"./src/system/tokens/*.yml\" -- npm run theo",
14+
"test:unit": "vue-cli-service test:unit"
2415
},
2516
"dependencies": {
2617
"vue": "^2.5.17"
@@ -30,9 +21,13 @@
3021
"@babel/standalone": "^7.0.0-beta.56",
3122
"@vue/cli-plugin-babel": "^3.0.0-rc.12",
3223
"@vue/cli-plugin-eslint": "^3.0.0-rc.12",
24+
"@vue/cli-plugin-unit-jest": "^3.0.1",
3325
"@vue/cli-service": "^3.0.0-rc.12",
3426
"@vue/eslint-config-prettier": "^3.0.0-rc.12",
27+
"@vue/test-utils": "^1.0.0-beta.20",
3528
"async-validator": "^1.8.5",
29+
"babel-core": "7.0.0-bridge.0",
30+
"babel-jest": "^23.0.1",
3631
"cheerio": "^1.0.0-rc.2",
3732
"clone-deep": "^4.0.0",
3833
"codemirror": "^5.39.2",
@@ -63,5 +58,15 @@
6358
"vuep": "git://github.com/visualjerk/vuep.git#iframe-preview",
6459
"webpack-bundle-analyzer": "^2.13.1",
6560
"webpack-merge-and-include-globally": "^2.0.11"
66-
}
61+
},
62+
"author": "visualjerk",
63+
"main": "./dist/system.umd.min.js",
64+
"files": [
65+
"dist/*",
66+
"src/*",
67+
"public/*",
68+
"*.json",
69+
"*.js"
70+
],
71+
"license": "MIT"
6772
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Heading.vue matches snapshot 1`] = `
4+
<h1
5+
class="ds-heading ds-heading-h1"
6+
>
7+
Winter is coming
8+
</h1>
9+
`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { shallowMount } from '@vue/test-utils'
2+
import Comp from './Heading.vue'
3+
4+
describe('Heading.vue', () => {
5+
let wrapper
6+
7+
beforeEach(() => {
8+
wrapper = shallowMount(Comp, {
9+
slots: {
10+
default: 'Winter is coming'
11+
}
12+
})
13+
})
14+
15+
it('defaults to h1', () => {
16+
expect(wrapper.props().tag).toEqual('h1')
17+
})
18+
19+
it('displays title', () => {
20+
expect(wrapper.text()).toEqual('Winter is coming')
21+
})
22+
23+
it('matches snapshot', () => {
24+
expect(wrapper.element).toMatchSnapshot()
25+
})
26+
})

tests/unit/.eslintrc.js

+8
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+
}

0 commit comments

Comments
 (0)