Skip to content

Commit 3b03d22

Browse files
2 parents f4798ce + 7314318 commit 3b03d22

File tree

5 files changed

+3442
-2
lines changed

5 files changed

+3442
-2
lines changed

.babelrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets": [
3+
["env", { "modules": false }]
4+
],
5+
"env": {
6+
"test": {
7+
"presets": [
8+
["env", { "targets": { "node": "current" }}]
9+
]
10+
}
11+
}
12+
}

package.json

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Mobile-friendly picture file input component with image preview and drag and drop.",
55
"main": "PictureInput.vue",
66
"scripts": {
7-
"test": "npm run unit"
7+
"test": "jest"
88
},
99
"repository": {
1010
"type": "git",
@@ -24,5 +24,32 @@
2424
"bugs": {
2525
"url": "https://github.com/alessiomaffeis/vue-picture-input/issues"
2626
},
27-
"homepage": "https://github.com/alessiomaffeis/vue-picture-input"
27+
"homepage": "https://github.com/alessiomaffeis/vue-picture-input",
28+
"devDependencies": {
29+
"@vue/test-utils": "^1.0.0-beta.12",
30+
"babel-core": "^6.26.0",
31+
"babel-preset-env": "^1.6.1",
32+
"jest": "^22.4.0",
33+
"jest-serializer-vue": "^0.3.0",
34+
"vue": "^2.5.13",
35+
"vue-jest": "^2.1.0",
36+
"vue-server-renderer": "^2.5.13",
37+
"vue-template-compiler": "^2.5.13"
38+
},
39+
"jest": {
40+
"moduleFileExtensions": [
41+
"js",
42+
"vue"
43+
],
44+
"moduleNameMapper": {
45+
"^@/(.*)$": "<rootDir>/src/$1"
46+
},
47+
"transform": {
48+
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
49+
".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
50+
},
51+
"snapshotSerializers": [
52+
"<rootDir>/node_modules/jest-serializer-vue"
53+
]
54+
}
2855
}

test/PictureInput.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { shallow } from '@vue/test-utils'
2+
import { createRenderer } from 'vue-server-renderer'
3+
4+
import PictureInput from '../PictureInput.vue'
5+
6+
describe('PictureInput.vue', () => {
7+
it('matches snapshot', () => {
8+
const renderer = createRenderer()
9+
const wrapper = shallow(PictureInput)
10+
renderer.renderToString(wrapper.vm, (err, str) => {
11+
if (err) throw new Error(err)
12+
expect(str).toMatchSnapshot()
13+
})
14+
})
15+
})
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`PictureInput.vue matches snapshot 1`] = `
4+
<div id="picture-input" class="picture-input">
5+
<div>
6+
<button class="btn btn-primary button">Select a Photo</button>
7+
</div>
8+
<input type="file" accept="image/*">
9+
</div>
10+
`;

0 commit comments

Comments
 (0)