added tests, not yet working

This commit is contained in:
2019-04-20 16:36:44 +02:00
parent 2e7553b70c
commit 74a823ad26
9 changed files with 1461 additions and 96 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
__pycache__ __pycache__
db.sqlite3 db.sqlite3
run_dev.sh

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,8 @@
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build", "build": "vue-cli-service build",
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint",
"test": "mocha-webpack --webpack-config node_modules/@vue/cli-service/webpack.config.js --require test/setup.js test/**/*.spec.js"
}, },
"dependencies": { "dependencies": {
"core-js": "^2.6.5", "core-js": "^2.6.5",
@@ -17,15 +18,22 @@
"@vue/cli-plugin-babel": "^3.5.0", "@vue/cli-plugin-babel": "^3.5.0",
"@vue/cli-plugin-eslint": "^3.5.0", "@vue/cli-plugin-eslint": "^3.5.0",
"@vue/cli-service": "^3.6.0", "@vue/cli-service": "^3.6.0",
"@vue/test-utils": "^1.0.0-beta.29",
"babel-eslint": "^10.0.1", "babel-eslint": "^10.0.1",
"chai": "^4.2.0",
"eslint": "^5.8.0", "eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0", "eslint-plugin-vue": "^5.0.0",
"jsdom": "^14.0.0",
"jsdom-global": "^3.0.2",
"mocha": "^6.1.4",
"mocha-webpack": "^1.1.0",
"stylus": "^0.54.5", "stylus": "^0.54.5",
"stylus-loader": "^3.0.1", "stylus-loader": "^3.0.1",
"vue-cli-plugin-vuetify": "^0.5.0", "vue-cli-plugin-vuetify": "^0.5.0",
"vue-template-compiler": "^2.5.21", "vue-template-compiler": "^2.5.21",
"vuetify-loader": "^1.0.5", "vuetify-loader": "^1.0.5",
"webpack-bundle-tracker": "^0.4.2-beta" "webpack-bundle-tracker": "^0.4.2-beta",
"webpack-node-externals": "^1.7.2"
}, },
"eslintConfig": { "eslintConfig": {
"root": true, "root": true,

View File

@@ -1,6 +1,30 @@
<template> <template>
<v-app> <v-app>
<v-toolbar app tabs> <v-navigation-drawer app v-model="showNav">
<v-list>
<v-list-tile>
<v-list-tile-title>
CookAssistant
</v-list-tile-title>
</v-list-tile>
</v-list>
<v-list dense>
<v-list-tile
v-for="link in links"
:key="link.path"
:to="link.path"
>
<v-list-tile-avatar>
<v-icon v-html="link.icon"
></v-icon>
</v-list-tile-avatar>
<v-list-tile-title v-html="link.text"
></v-list-tile-title>
</v-list-tile>
</v-list>
</v-navigation-drawer>
<v-toolbar app>
<v-toolbar-side-icon <v-toolbar-side-icon
@click.stop="showNav = !showNav" @click.stop="showNav = !showNav"
></v-toolbar-side-icon> ></v-toolbar-side-icon>
@@ -21,29 +45,11 @@
<router-view name="extension"></router-view> <router-view name="extension"></router-view>
</template> </template>
</v-toolbar> </v-toolbar>
<v-navigation-drawer
fixed
app
clipped
v-model="showNav"
>
<v-list dense>
<v-list-tile
v-for="link in links"
:key="link.path"
:to="link.path"
>
<v-list-tile-avatar>
<v-icon v-html="link.icon"
></v-icon>
</v-list-tile-avatar>
<v-list-tile-title v-html="link.text"
></v-list-tile-title>
</v-list-tile>
</v-list>
</v-navigation-drawer>
<v-content> <v-content>
<v-container fluid>
<router-view></router-view> <router-view></router-view>
</v-container>
</v-content> </v-content>
</v-app> </v-app>
</template> </template>

View File

@@ -1,6 +1,5 @@
<template> <template>
<!-- Categories list --> <!-- Categories list -->
<span>
<v-tabs v-if="showTabs" :mandatory="false"> <v-tabs v-if="showTabs" :mandatory="false">
<v-tab v-for="key in Object.keys(categories)" <v-tab v-for="key in Object.keys(categories)"
:key="`cat-${key}`" :key="`cat-${key}`"
@@ -8,17 +7,11 @@
{{ categories[key] }} {{ categories[key] }}
</v-tab> </v-tab>
</v-tabs> </v-tabs>
<template v-else> <v-btn v-else
<v-toolbar-title>
Détails
</v-toolbar-title>
<v-btn v-show="!showTabs"
icon icon
@click="$router.go(-1)" @click="$router.go(-1)"
><v-icon>arrow_back</v-icon></v-btn> ><v-icon>arrow_back</v-icon></v-btn>
</template> </template>
</span>
</template>
<script> <script>

View File

@@ -0,0 +1,10 @@
import { shallowMount } from '@vue/test-utils'
import RessourceField from '../src/components/RessourceField'
describe('RessourceField.vue', () => {
it('first test', () => {
let field = shallowMount(RessourceField)
expect(field).to.equal("Name")
})
})

6
frontend/test/setup.js Normal file
View File

@@ -0,0 +1,6 @@
require('jsdom-global')(undefined, { pretendToBeVisual: true, url: 'http://localhost' })
window.Date = Date
global.expect = require('chai').expect
// See https://github.com/vuejs/vue-cli/issues/2128#issuecomment-453109575

View File

@@ -1,4 +1,5 @@
const BundleTracker = require("webpack-bundle-tracker"); const BundleTracker = require("webpack-bundle-tracker");
const nodeExternals = require("webpack-node-externals");
module.exports = { module.exports = {
publicPath: "http://localhost:8080/", publicPath: "http://localhost:8080/",
@@ -6,6 +7,8 @@ module.exports = {
chainWebpack: config => { chainWebpack: config => {
config.devtool = "inline-cheap-module-source-map",
config.externals = [nodeExternals()],
config.optimization config.optimization
.splitChunks(false) .splitChunks(false)

View File

@@ -1 +1 @@
{"status":"done","publicPath":"http://localhost:8080/","chunks":{"null":[{"name":"0.js","publicPath":"http://localhost:8080/0.js","path":"/home/artus/Documents/cookAssistant/frontend/dist/0.js"},{"name":"0.880af34e5f0e1c2d5443.hot-update.js","publicPath":"http://localhost:8080/0.880af34e5f0e1c2d5443.hot-update.js","path":"/home/artus/Documents/cookAssistant/frontend/dist/0.880af34e5f0e1c2d5443.hot-update.js"}],"app":[{"name":"app.js","publicPath":"http://localhost:8080/app.js","path":"/home/artus/Documents/cookAssistant/frontend/dist/app.js"}]},"error":"ModuleBuildError","message":"Module build failed (from ./node_modules/babel-loader/lib/index.js):\nSyntaxError: /home/artus/Documents/cookAssistant/frontend/src/components/recipes/IngredientList.vue: Unexpected token (85:70)\n\n 83 | )\n 84 | .then(data => {\n> 85 | var idx = this.edited_ingdts.indexOf(i => i.ingredient.id ==)\n | ^\n 86 | })\n 87 | .catch(err => comp.errors.push(JSON.stringify(err)))\n 88 | },\n at Object.raise (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:3851:17)\n at Object.unexpected (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:5167:16)\n at Object.parseExprAtom (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:6328:20)\n at Object.parseExprAtom (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:3570:20)\n at Object.parseExprSubscripts (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:5914:23)\n at Object.parseMaybeUnary (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:5894:21)\n at Object.parseExprOpBaseRightExpr (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:5854:34)\n at Object.parseExprOpRightExpr (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:5847:21)\n at Object.parseExprOp (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:5826:27)\n at Object.parseExprOps (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:5791:17)\n at Object.parseMaybeConditional (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:5754:23)\n at Object.parseMaybeAssign (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:5701:21)\n at Object.parseFunctionBody (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:6891:24)\n at Object.parseArrowExpression (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:6851:10)\n at Object.parseExprAtom (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:6213:18)\n at Object.parseExprAtom (/home/artus/Documents/cookAssistant/frontend/node_modules/@babel/parser/lib/index.js:3570:20)"} {"status":"done","publicPath":"http://localhost:8080/","chunks":{"null":[{"name":"0.js","publicPath":"http://localhost:8080/0.js","path":"/home/artus/Documents/cookAssistant/frontend/dist/0.js"}],"app":[{"name":"app.js","publicPath":"http://localhost:8080/app.js","path":"/home/artus/Documents/cookAssistant/frontend/dist/app.js"}]},"error":"ModuleError","message":"Module Error (from ./node_modules/vue-loader/lib/loaders/templateLoader.js):\n(Emitted value instead of an instance of Error) \n\n Errors compiling template:\n\n tag <span> has no matching end tag.\n\n 1 | \n 2 | <!-- Categories list -->\n | \n 3 | <span>\n | ^^^^^^\n 4 | <v-tabs v-if=\"showTabs\" :mandatory=\"false\">\n"}