Skip to content

Commit 11a55b3

Browse files
committed
test: init unit tests. update docs and dependencies
1 parent e7ee73a commit 11a55b3

File tree

10 files changed

+489
-926
lines changed

10 files changed

+489
-926
lines changed

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,21 @@ Vue.use(VueImageKit)
8484
and then import it in your `nuxt.config.js` file
8585
```js
8686
plugins: [
87-
'~/plugins/vue-image-kit.js'
87+
{ src: '~/plugins/vue-image-kit', mode: 'client' }
8888
]
8989
```
9090

9191
## Basic usage
9292

9393
```html
9494
<template>
95-
<div>
96-
<div style="height:4500px;width:100vw;background:gray">&nbsp;</div>
97-
<vue-image-kit
98-
hash="6xhf1gnexgdgk"
99-
src="lion_BllLvaqVn.jpg"
100-
width="1400px"
101-
height="800px"
102-
alt="Lion image"
103-
/>
104-
</div>
95+
<vue-image-kit
96+
hash="6xhf1gnexgdgk"
97+
src="lion_BllLvaqVn.jpg"
98+
:width="1400"
99+
:height="800"
100+
alt="Lion image"
101+
/>
105102
</template>
106103
```
107104

@@ -117,8 +114,8 @@ plugins: [
117114
| sizes | Array | [] | false | Array of numbers that will define the images sizes attribute. Each number correspond to one of the images max-width. Empty by default, which gets each of the images srcset prop and subtract by 40px |
118115
| defaultSize | Number | 1080 | true | Images default size. Must be larger than the largest srcset and sizes |
119116
| customTransform | String | '' | false | Use this to append any extra image kit transform that you want |
120-
| width | String | '' | false | Images width. Any valid CSS unit It will be set with inline style |
121-
| height | String | '' | false | Images height. Any valid CSS unit. It will be set with inline style |
117+
| width | Number | null | false | Images width. Width number in pixels. It will be set with inline style |
118+
| height | Number | null | false | Images height. Height number in pixels. It will be set with inline style |
122119
| alt | String | '' | false | Images alt attribute |
123120

124121
## Development

jest.config.js

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
11
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|svg|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)'
21-
],
22-
testURL: 'http://localhost/',
2+
preset: '@vue/cli-plugin-unit-jest',
233
coverageDirectory: './coverage/',
24-
collectCoverage: true,
25-
transformIgnorePatterns: [
26-
'node_modules/(?!(babel-jest|jest-vue-preprocessor)/)'
27-
]
4+
collectCoverage: true
285
}

package.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"vue": "^2.6.10"
2020
},
2121
"devDependencies": {
22-
"@babel/preset-env": "^7.7.4",
2322
"@commitlint/cli": "^8.2.0",
2423
"@commitlint/config-conventional": "^8.2.0",
2524
"@storybook/addon-actions": "^5.2.6",
@@ -31,20 +30,15 @@
3130
"@vue/cli-plugin-eslint": "^4.1.1",
3231
"@vue/cli-plugin-unit-jest": "^4.1.1",
3332
"@vue/cli-service": "^4.1.1",
34-
"@vue/eslint-config-standard": "^5.0.0",
33+
"@vue/eslint-config-standard": "^4.0.0",
3534
"@vue/test-utils": "^1.0.0-beta.29",
36-
"babel-core": "6.26.3",
3735
"babel-eslint": "^10.0.3",
38-
"babel-jest": "^24.9.0",
3936
"commitizen": "^4.0.3",
4037
"core-js": "3.4.5",
41-
"eslint": "^6.7.1",
42-
"eslint-plugin-import": "^2.18.2",
43-
"eslint-plugin-node": "^10.0.0",
44-
"eslint-plugin-promise": "^4.2.1",
45-
"eslint-plugin-standard": "^4.0.1",
46-
"eslint-plugin-vue": "^6.0.1",
38+
"eslint": "^5.16.0",
39+
"eslint-plugin-vue": "^5.0.0s",
4740
"husky": "^3.1.0",
41+
"jest-canvas-mock": "^2.2.0",
4842
"vue-cli-plugin-storybook": "^0.6.1",
4943
"vue-template-compiler": "^2.6.10"
5044
},

src/components/VueImageKit.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
22
<div class="vue-image-kit">
33
<div v-if="dataUrl" :style="{ backgroundColor }" class="vue-image-kit__placeholder">
4-
<img :src="placeholder || dataUrl" :alt="alt" :style="{ width, height }">
4+
<img :src="placeholder || dataUrl" alt="Placeholder" :style="{ width: `${width}px`, height: `${height}px` }">
55
</div>
6-
<img :srcset="getSrcset" :sizes="getSizes" :src="getSrc" :alt="alt" :style="{ width, height }" class="vue-image-kit__img"/>
6+
<img :srcset="getSrcset" :sizes="getSizes" :src="getSrc" :alt="alt" :style="{ width: `${width}px`, height: `${height}px` }" class="vue-image-kit__img"/>
77
</div>
88
</template>
99

@@ -28,12 +28,12 @@ export default {
2828
default: ''
2929
},
3030
width: {
31-
type: String,
32-
default: ''
31+
type: Number,
32+
default: null
3333
},
3434
height: {
35-
type: String,
36-
default: ''
35+
type: Number,
36+
default: null
3737
},
3838
alt: {
3939
type: String,

stories/index.stories.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ timelineStory.add('Default', () => {
3636
type: String,
3737
default: text('Placeholder', '')
3838
},
39-
background: {
39+
backgroundColor: {
4040
type: String,
4141
default: text('Background', '')
4242
},
@@ -73,7 +73,7 @@ timelineStory.add('Default', () => {
7373
:hash="hash"
7474
:src="src"
7575
:placeholder="placeholder"
76-
:background="background"
76+
:background-color="backgroundColor"
7777
:srcset="srcset"
7878
:sizes="sizes"
7979
:width="width"

tests/unit/__snapshots__/vue-horizontal-timeline.spec.js.snap

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`When I create the VueImageKit component should match snapshot 1`] = `
4+
<div class="vue-image-kit">
5+
<!----> <img srcset="/6xhf1gnexgdgk/tr:w-320/lion_BllLvaqVn.jpg 320w, /6xhf1gnexgdgk/tr:w-480/lion_BllLvaqVn.jpg 480w, /6xhf1gnexgdgk/tr:w-800/lion_BllLvaqVn.jpg 800w" sizes="(max-width: 320px) 280px, (max-width: 480px) 440px, (max-width: 800px) 760px 1080px" src="" alt="" class="vue-image-kit__img"></div>
6+
`;

0 commit comments

Comments
 (0)