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

Commit

Permalink
Merge pull request #217 from asigloo/feature/unit-test
Browse files Browse the repository at this point in the history
Feature/unit test & E2E
  • Loading branch information
alvarosabu authored Jan 10, 2021
2 parents b63076f + 571f6af commit ff62de0
Show file tree
Hide file tree
Showing 90 changed files with 12,731 additions and 6,409 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/
*.config.js
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,14 @@ module.exports = {
jest: true,
},
},
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)',
],
env: {
jest: true,
},
},
],
};
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ jobs:
node-version: 12
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm run test --verbose
- name: Build Library
run: npm run build
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
node-version: 12
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm run test --verbose
- name: Run e2e
run: npm run test:e2e
- name: Build Library
run: npm run build
- name: Build Types Declarations
Expand Down
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname $0)/_/husky.sh"

npm run lint
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname $0)/_/husky.sh"

npm test
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.vuegenerator
.eslintrc.js
.eslintignore
.husky
netlify.toml
jest.config.js
babel.config.js
Expand Down
1 change: 1 addition & 0 deletions .nyc_output/out.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"baseUrl": "http://localhost:6044",
"pluginsFile": "tests/e2e/plugins/index.js",
"testFiles": "**/*.e2e.js*"
}
23 changes: 23 additions & 0 deletions demos/vue-3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist


# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
24 changes: 24 additions & 0 deletions demos/vue-3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# vue-3

## Project setup
```
yarn install
```

### Compiles and hot-reloads for development
```
yarn serve
```

### Compiles and minifies for production
```
yarn build
```

### Lints and fixes files
```
yarn lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
Binary file added demos/vue-3/public/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions demos/vue-3/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
20 changes: 20 additions & 0 deletions demos/vue-3/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div id="app">
<Toolbar />
<router-view />
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import Toolbar from './components/Toolbar.vue';
const components = {
Toolbar,
};
export default defineComponent({
name: 'app',
components,
});
</script>
Binary file added demos/vue-3/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions demos/vue-3/src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions demos/vue-3/src/components/Console.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<div class="console bg-marine text-white text-xs p-4 rounded-md relative">
<ul class="absolute top-1 left-2">
<li class="rounded w-2 h-2 bg-salmon inline-block mr-1"></li>
<li class="rounded w-2 h-2 bg-yellow-300 inline-block mr-1"></li>
<li class="rounded w-2 h-2 bg-green-500 inline-block"></li>
</ul>
<pre
data-cy="form-values"
class="shadow-lg pt-4"
:data-formValues="jsonValues"
>{{ content }}</pre
>
</div>
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue';
const props = {
content: String,
};
export default defineComponent({
name: 'console',
props,
setup(props) {
const jsonValues = computed(() => JSON.stringify(props.content));
return {
jsonValues,
};
},
});
</script>

<style></style>
30 changes: 30 additions & 0 deletions demos/vue-3/src/components/Toolbar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<header class="toolbar flex px-8 py-4 border-b border-gray-100">
<img src="../assets/logo.svg" class="logo mr-8" />
<h1 class="text-bg text-xl font-bold font-display text-gray-700">
{{ title }}
</h1>
</header>
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue';
import { useRoute } from 'vue-router';
export default defineComponent({
name: 'toolbar',
setup() {
const route = useRoute();
const title = computed(() => route.meta.title || 'Vue Dynamic Forms');
return { title };
},
});
</script>

<style>
.logo {
width: 32px;
height: 32px;
}
</style>
22 changes: 22 additions & 0 deletions demos/vue-3/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { createApp } from 'vue';
import App from './App.vue';
import './styles/main.scss';
import router from './router';

import { createDynamicForms } from '../../../src';

const VueDynamicForms = createDynamicForms({
autoValidate: true,
form: {
customClass: 'plugin-options-class-added',
method: 'POST',
netlify: false,
netlifyHoneypot: null,
},
});

export const app = createApp(App);

app.use(VueDynamicForms);

app.use(router).mount('#app');
102 changes: 102 additions & 0 deletions demos/vue-3/src/router/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import Home from '../views/Home.vue';

const routes: Array<RouteRecordRaw> = [
{
path: '/',
name: 'Home',
component: Home,
},
{
path: '/general',
name: 'General',
meta: {
title: 'General',
},
component: () =>
import(/* webpackChunkName: "general" */ '../views/General.vue'),
},
{
path: '/basic',
name: 'Basic',
meta: {
title: 'Basic',
},
component: () =>
import(/* webpackChunkName: "basic" */ '../views/Basic.vue'),
},
{
path: '/text-fields',
name: 'Text Fields',
meta: {
title: 'Text Fields',
},
component: () =>
import(/* webpackChunkName: "text-fields" */ '../views/TextFields.vue'),
},
{
path: '/number-fields',
name: 'Number Fields',
meta: {
title: 'Number Fields',
},
component: () =>
import(/* webpackChunkName: "text-fields" */ '../views/NumberFields.vue'),
},
{
path: '/select-fields',
name: 'Select Fields',
meta: {
title: 'Select Fields',
},
component: () =>
import(/* webpackChunkName: "text-fields" */ '../views/SelectFields.vue'),
},
{
path: '/textarea-fields',
name: 'TextArea Fields',
meta: {
title: 'TextArea Fields',
},
component: () =>
import(
/* webpackChunkName: "text-fields" */ '../views/TextAreaFields.vue'
),
},
{
path: '/checkbox-fields',
name: 'Checkbox Fields',
meta: {
title: 'Checkbox Fields',
},
component: () =>
import(
/* webpackChunkName: "checkbox-fields" */ '../views/CheckboxFields.vue'
),
},
{
path: '/radio-fields',
name: 'Radio Fields',
meta: {
title: 'Radio Fields',
},
component: () =>
import(/* webpackChunkName: "radio-fields" */ '../views/RadioFields.vue'),
},
{
path: '/login',
name: 'Login',
meta: {
title: 'Login',
},
component: () =>
import(/* webpackChunkName: "campaigns" */ '../views/Login.vue'),
},
];

const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes,
});

export default router;
5 changes: 5 additions & 0 deletions demos/vue-3/src/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.vue' {
import { defineComponent } from 'vue';
const component: ReturnType<typeof defineComponent>;
export default component;
}
7 changes: 7 additions & 0 deletions demos/vue-3/src/styles/_vendors.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import 'tailwindcss/base';

@import 'tailwindcss/components';

@import 'tailwindcss/utilities';

@import '@/styles/themes/default.scss';
16 changes: 13 additions & 3 deletions dev/vue/styles/base.scss → demos/vue-3/src/styles/base.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
@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');

.card {
@apply max-w-lg w-full rounded-lg shadow-lg;
@apply w-full rounded-lg shadow-lg border border-gray-100;
}

.text-bg {
background-image: linear-gradient(
to top,
#99ffd580 54%,
transparent 54%,
transparent 100%
);
width: fit-content;
}

.container {
Expand All @@ -16,8 +26,8 @@
@apply font-serif font-bold text-gray-800 text-2xl;
}

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

.btn {
Expand Down
File renamed without changes.
Loading

0 comments on commit ff62de0

Please sign in to comment.