Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit ff62de0

Browse files
authored
Merge pull request #217 from asigloo/feature/unit-test
Feature/unit test & E2E
2 parents b63076f + 571f6af commit ff62de0

File tree

90 files changed

+12731
-6409
lines changed

Some content is hidden

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

90 files changed

+12731
-6409
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
dist/
2+
*.config.js

.eslintrc.js

+9
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,14 @@ module.exports = {
3535
jest: true,
3636
},
3737
},
38+
{
39+
files: [
40+
'**/__tests__/*.{j,t}s?(x)',
41+
'**/tests/unit/**/*.spec.{j,t}s?(x)',
42+
],
43+
env: {
44+
jest: true,
45+
},
46+
},
3847
],
3948
};

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ jobs:
1717
node-version: 12
1818
- name: Install dependencies
1919
run: npm ci
20+
- name: Run unit tests
21+
run: npm run test --verbose
2022
- name: Build Library
2123
run: npm run build

.github/workflows/release.yml

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ jobs:
1717
node-version: 12
1818
- name: Install dependencies
1919
run: npm ci
20+
- name: Run unit tests
21+
run: npm run test --verbose
22+
- name: Run e2e
23+
run: npm run test:e2e
2024
- name: Build Library
2125
run: npm run build
2226
- name: Build Types Declarations

.husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname $0)/_/husky.sh"
3+
4+
npm run lint

.husky/pre-push

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname $0)/_/husky.sh"
3+
4+
npm test

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.vuegenerator
33
.eslintrc.js
44
.eslintignore
5+
.husky
56
netlify.toml
67
jest.config.js
78
babel.config.js

.nyc_output/out.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

cypress.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"baseUrl": "http://localhost:6044",
3+
"pluginsFile": "tests/e2e/plugins/index.js",
4+
"testFiles": "**/*.e2e.js*"
5+
}

demos/vue-3/.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?

demos/vue-3/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# vue-3
2+
3+
## Project setup
4+
```
5+
yarn install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
yarn serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
yarn build
16+
```
17+
18+
### Lints and fixes files
19+
```
20+
yarn lint
21+
```
22+
23+
### Customize configuration
24+
See [Configuration Reference](https://cli.vuejs.org/config/).

demos/vue-3/public/favicon.ico

4.19 KB
Binary file not shown.

demos/vue-3/public/index.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
8+
<title><%= htmlWebpackPlugin.options.title %></title>
9+
</head>
10+
<body>
11+
<noscript>
12+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
13+
</noscript>
14+
<div id="app"></div>
15+
<!-- built files will be auto injected -->
16+
</body>
17+
</html>

demos/vue-3/src/App.vue

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<div id="app">
3+
<Toolbar />
4+
<router-view />
5+
</div>
6+
</template>
7+
8+
<script lang="ts">
9+
import { defineComponent } from 'vue';
10+
import Toolbar from './components/Toolbar.vue';
11+
12+
const components = {
13+
Toolbar,
14+
};
15+
16+
export default defineComponent({
17+
name: 'app',
18+
components,
19+
});
20+
</script>

demos/vue-3/src/assets/logo.png

8.44 KB
Loading

demos/vue-3/src/assets/logo.svg

+1
Loading
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<template>
2+
<div class="console bg-marine text-white text-xs p-4 rounded-md relative">
3+
<ul class="absolute top-1 left-2">
4+
<li class="rounded w-2 h-2 bg-salmon inline-block mr-1"></li>
5+
<li class="rounded w-2 h-2 bg-yellow-300 inline-block mr-1"></li>
6+
<li class="rounded w-2 h-2 bg-green-500 inline-block"></li>
7+
</ul>
8+
<pre
9+
data-cy="form-values"
10+
class="shadow-lg pt-4"
11+
:data-formValues="jsonValues"
12+
>{{ content }}</pre
13+
>
14+
</div>
15+
</template>
16+
17+
<script lang="ts">
18+
import { computed, defineComponent } from 'vue';
19+
20+
const props = {
21+
content: String,
22+
};
23+
24+
export default defineComponent({
25+
name: 'console',
26+
props,
27+
setup(props) {
28+
const jsonValues = computed(() => JSON.stringify(props.content));
29+
return {
30+
jsonValues,
31+
};
32+
},
33+
});
34+
</script>
35+
36+
<style></style>
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<template>
2+
<header class="toolbar flex px-8 py-4 border-b border-gray-100">
3+
<img src="../assets/logo.svg" class="logo mr-8" />
4+
<h1 class="text-bg text-xl font-bold font-display text-gray-700">
5+
{{ title }}
6+
</h1>
7+
</header>
8+
</template>
9+
10+
<script lang="ts">
11+
import { computed, defineComponent } from 'vue';
12+
import { useRoute } from 'vue-router';
13+
14+
export default defineComponent({
15+
name: 'toolbar',
16+
setup() {
17+
const route = useRoute();
18+
const title = computed(() => route.meta.title || 'Vue Dynamic Forms');
19+
20+
return { title };
21+
},
22+
});
23+
</script>
24+
25+
<style>
26+
.logo {
27+
width: 32px;
28+
height: 32px;
29+
}
30+
</style>

demos/vue-3/src/main.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { createApp } from 'vue';
2+
import App from './App.vue';
3+
import './styles/main.scss';
4+
import router from './router';
5+
6+
import { createDynamicForms } from '../../../src';
7+
8+
const VueDynamicForms = createDynamicForms({
9+
autoValidate: true,
10+
form: {
11+
customClass: 'plugin-options-class-added',
12+
method: 'POST',
13+
netlify: false,
14+
netlifyHoneypot: null,
15+
},
16+
});
17+
18+
export const app = createApp(App);
19+
20+
app.use(VueDynamicForms);
21+
22+
app.use(router).mount('#app');

demos/vue-3/src/router/index.ts

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
2+
import Home from '../views/Home.vue';
3+
4+
const routes: Array<RouteRecordRaw> = [
5+
{
6+
path: '/',
7+
name: 'Home',
8+
component: Home,
9+
},
10+
{
11+
path: '/general',
12+
name: 'General',
13+
meta: {
14+
title: 'General',
15+
},
16+
component: () =>
17+
import(/* webpackChunkName: "general" */ '../views/General.vue'),
18+
},
19+
{
20+
path: '/basic',
21+
name: 'Basic',
22+
meta: {
23+
title: 'Basic',
24+
},
25+
component: () =>
26+
import(/* webpackChunkName: "basic" */ '../views/Basic.vue'),
27+
},
28+
{
29+
path: '/text-fields',
30+
name: 'Text Fields',
31+
meta: {
32+
title: 'Text Fields',
33+
},
34+
component: () =>
35+
import(/* webpackChunkName: "text-fields" */ '../views/TextFields.vue'),
36+
},
37+
{
38+
path: '/number-fields',
39+
name: 'Number Fields',
40+
meta: {
41+
title: 'Number Fields',
42+
},
43+
component: () =>
44+
import(/* webpackChunkName: "text-fields" */ '../views/NumberFields.vue'),
45+
},
46+
{
47+
path: '/select-fields',
48+
name: 'Select Fields',
49+
meta: {
50+
title: 'Select Fields',
51+
},
52+
component: () =>
53+
import(/* webpackChunkName: "text-fields" */ '../views/SelectFields.vue'),
54+
},
55+
{
56+
path: '/textarea-fields',
57+
name: 'TextArea Fields',
58+
meta: {
59+
title: 'TextArea Fields',
60+
},
61+
component: () =>
62+
import(
63+
/* webpackChunkName: "text-fields" */ '../views/TextAreaFields.vue'
64+
),
65+
},
66+
{
67+
path: '/checkbox-fields',
68+
name: 'Checkbox Fields',
69+
meta: {
70+
title: 'Checkbox Fields',
71+
},
72+
component: () =>
73+
import(
74+
/* webpackChunkName: "checkbox-fields" */ '../views/CheckboxFields.vue'
75+
),
76+
},
77+
{
78+
path: '/radio-fields',
79+
name: 'Radio Fields',
80+
meta: {
81+
title: 'Radio Fields',
82+
},
83+
component: () =>
84+
import(/* webpackChunkName: "radio-fields" */ '../views/RadioFields.vue'),
85+
},
86+
{
87+
path: '/login',
88+
name: 'Login',
89+
meta: {
90+
title: 'Login',
91+
},
92+
component: () =>
93+
import(/* webpackChunkName: "campaigns" */ '../views/Login.vue'),
94+
},
95+
];
96+
97+
const router = createRouter({
98+
history: createWebHistory(process.env.BASE_URL),
99+
routes,
100+
});
101+
102+
export default router;

demos/vue-3/src/shims-vue.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module '*.vue' {
2+
import { defineComponent } from 'vue';
3+
const component: ReturnType<typeof defineComponent>;
4+
export default component;
5+
}

demos/vue-3/src/styles/_vendors.scss

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@import 'tailwindcss/base';
2+
3+
@import 'tailwindcss/components';
4+
5+
@import 'tailwindcss/utilities';
6+
7+
@import '@/styles/themes/default.scss';

dev/vue/styles/base.scss renamed to demos/vue-3/src/styles/base.scss

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,600;0,700;1,400&family=Roboto:wght@300;500;700&display=swap');
22

33
.card {
4-
@apply max-w-lg w-full rounded-lg shadow-lg;
4+
@apply w-full rounded-lg shadow-lg border border-gray-100;
5+
}
6+
7+
.text-bg {
8+
background-image: linear-gradient(
9+
to top,
10+
#99ffd580 54%,
11+
transparent 54%,
12+
transparent 100%
13+
);
14+
width: fit-content;
515
}
616

717
.container {
@@ -16,8 +26,8 @@
1626
@apply font-serif font-bold text-gray-800 text-2xl;
1727
}
1828

19-
pre {
20-
@apply bg-gray-900 text-white text-xs p-4 rounded-md;
29+
.chip {
30+
@apply text-xs rounded-full bg-gray-300 mr-4 py-1 px-2 font-thin;
2131
}
2232

2333
.btn {
File renamed without changes.

0 commit comments

Comments
 (0)