Skip to content

Commit ee05436

Browse files
author
utkace
committed
test: add test cases
1 parent 86ceaaa commit ee05436

File tree

5 files changed

+114
-0
lines changed

5 files changed

+114
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import IKImage from '../../src/components/IKImage.vue';
2+
import IKContext from '../../src/components/IKContext.vue';
3+
export default {
4+
title: 'IKContext',
5+
};
6+
7+
8+
const urlEndpoint = process.env.VUE_APP_URL_ENDPOINT;
9+
const publicKey = process.env.VUE_APP_PUBLIC_KEY;
10+
11+
export const imageWithContext = () => ({
12+
components: { IKImage, IKContext },
13+
template: `<IKContext publicKey="${publicKey}" urlEndpoint=${urlEndpoint}><IKImage src="https://ik.imagekit.io/gqyojxcwzxj/ABC_BV8lzpfOS"/></IKContext>`,
14+
});
15+
16+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import IKImage from '../../src/components/IKImage.vue';
2+
3+
export default {
4+
title: 'IKImage',
5+
};
6+
7+
const urlEndpoint = process.env.VUE_APP_URL_ENDPOINT;
8+
const publicKey = process.env.VUE_APP_PUBLIC_KEY;
9+
10+
export const imageWithSrc = () => ({
11+
components: { IKImage },
12+
template: `<IKImage publicKey="${publicKey}" urlEndpoint=${urlEndpoint} src="https://ik.imagekit.io/gqyojxcwzxj/ABC_BV8lzpfOS"/>`,
13+
});
14+
15+
export const imageWithPath = () => ({
16+
components: { IKImage },
17+
template: `<IKImage publicKey="${publicKey}" urlEndpoint=${urlEndpoint} path="/ABC_BV8lzpfOS"/>`,
18+
});
19+
20+
export const imageWithLQIP = () => ({
21+
components: { IKImage },
22+
template: `<IKImage publicKey="${publicKey}" urlEndpoint=${urlEndpoint} src="https://ik.imagekit.io/gqyojxcwzxj/ABC_BV8lzpfOS" v-bind:lqip="{active:true,threshold:20}"/>`,
23+
});
24+
25+
export const imageWithNoPublicKey = () => ({
26+
components: { IKImage },
27+
template: `<IKImage publicKey="" urlEndpoint=${urlEndpoint} src="https://ik.imagekit.io/gqyojxcwzxj/ABC_BV8lzpfOS"/>`,
28+
});
29+
30+
export const imageWithNoUrlEndpoint = () => ({
31+
components: { IKImage },
32+
template: `<IKImage publicKey="${publicKey}" urlEndpoint="" src="https://ik.imagekit.io/gqyojxcwzxj/ABC_BV8lzpfOS"/>`,
33+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import IKImage from '../../src/components/IKImage.vue';
2+
3+
export default {
4+
title: 'Transformations',
5+
};
6+
7+
const urlEndpoint = process.env.VUE_APP_URL_ENDPOINT;
8+
const publicKey = process.env.VUE_APP_PUBLIC_KEY;
9+
10+
export const imageWithTransformation = () => ({
11+
components: { IKImage },
12+
template: `<IKImage publicKey="${publicKey}" urlEndpoint=${urlEndpoint} src="https://ik.imagekit.io/gqyojxcwzxj/ABC_BV8lzpfOS" v-bind:transformation="[{height:300,width:400}]" />`,
13+
});
14+
15+
export const imageWithChainedTransformation = () => ({
16+
components: { IKImage },
17+
template: `<IKImage publicKey="${publicKey}" urlEndpoint=${urlEndpoint} src="https://ik.imagekit.io/gqyojxcwzxj/ABC_BV8lzpfOS" v-bind:transformation="[{height:300,width:400},{rotation:90}]" />`,
18+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import IKUpload from '../../src/components/IKUpload.vue';
2+
import IKContext from '../../src/components/IKContext.vue';
3+
export default {
4+
title: 'IKUpload',
5+
};
6+
7+
const urlEndpoint = process.env.VUE_APP_URL_ENDPOINT;
8+
const publicKey = process.env.VUE_APP_PUBLIC_KEY;
9+
const authenticationEndpoint = process.env.VUE_APP_AUTHENTICATION_ENDPOINT;
10+
11+
export const ImageUpload = () => ({
12+
components: { IKUpload,IKContext },
13+
template: `<IKContext publicKey="${publicKey}" urlEndpoint=${urlEndpoint} authenticationEndpoint=${authenticationEndpoint}><IKUpload fileName="new"/></IKContext>`,
14+
});
15+
16+
export const ImageUploadwithAllProps = () => ({
17+
components: { IKUpload,IKContext },
18+
template: `<IKContext publicKey="${publicKey}" urlEndpoint=${urlEndpoint} authenticationEndpoint=${authenticationEndpoint}><IKUpload fileName="'new'" v-bind:useUniqueFileName="true" v-bind:tags="['tag1', 'tag2', 'tag3']" v-bind:folder="'/'" v-bind:isPrivateFile="true" v-bind:customCoordinates="'0,0,0,0'" v-bind:responseFields="['tags', 'isPrivateFile', 'customCoordinates']" /></IKContext>`,
19+
});
20+
21+
export const ImageUploadwithNoTags = () => ({
22+
components: { IKUpload,IKContext },
23+
template: `<IKContext publicKey="${publicKey}" urlEndpoint=${urlEndpoint} authenticationEndpoint=${authenticationEndpoint}><IKUpload fileName="'new'" v-bind:useUniqueFileName="true" v-bind:folder="'/'" v-bind:isPrivateFile="true" v-bind:customCoordinates="'0,0,0,0'" v-bind:responseFields="['isPrivateFile', 'customCoordinates']" /></IKContext>`,
24+
});
25+
26+
export const ImageUploadwithNoCustomCoordinates = () => ({
27+
components: { IKUpload,IKContext },
28+
template: `<IKContext publicKey="${publicKey}" urlEndpoint=${urlEndpoint} authenticationEndpoint=${authenticationEndpoint}><IKUpload fileName="'new'" v-bind:useUniqueFileName="false" v-bind:tags="['tag1', 'tag2', 'tag3']" v-bind:folder="'/'" v-bind:isPrivateFile="false" v-bind:responseFields="['tags', 'isPrivateFile']" /></IKContext>`,
29+
});
30+
31+
export const ImageUploadnoAuthentication = () => ({
32+
components: { IKUpload,IKContext },
33+
template: `<IKContext publicKey="${publicKey}" urlEndpoint=${urlEndpoint} authenticationEndpoint=""><IKUpload fileName="new"/></IKContext>`,
34+
});
35+

tests/storyshots.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import initStoryshots from '@storybook/addon-storyshots';
2+
3+
initStoryshots({ /* configuration options */ });
4+
5+
// Dates get changed in snapshots depending on timezone of bulding machine,
6+
// So we set a default date or moment for all dates.
7+
const DATE_TO_USE = new Date('2019');
8+
const _Date = Date;
9+
global.Date = jest.fn(() => DATE_TO_USE);
10+
global.Date.UTC = _Date.UTC;
11+
global.Date.parse = _Date.parse;
12+
global.Date.now = _Date.now;

0 commit comments

Comments
 (0)