Name : Fran
Email : Frmm97@gmail.com
Assignment for Web dev This is the server for the Client the https://github.com/FranciscaMasombo/weight-watchers-client
let SubmissionSchema = new mongoose.Schema({
fname: { type:String, required: true},
lname: { type:String, required: true},
email: { type: String, required: true },
number: { type: String, required: true },
gender: { type:String, required: true},
age: { type: Number, min: 16, max: 100, required: true },
startWeight: { type:Number, required: true },
goalWeight:{ type:Number, required: true },
currentWeight:{ type:Number, required: true},
height:{ type:Number},
location:{ type:String, required: true },
date: { type: Date, default: Date.now, },
note: {type: String, required: true},
user: {type: UserSchema.ObjectId, ref: 'user'},
}, {collection: 'sub'});
$ npm cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/submissions-model-test.js
$ npm cross-env NODE_ENV=test PORT=4000 nyc mocha test/submissions-model-test.js",
$ npm nyc report --reporter=text-lcov | coveralls
https://travis-ci.org/FranciscaMasombo/weight-watchers-server
➥ SUBMISSION TESTS
Is there anything in the database
Successfully Connected to [ ccwtracker-test ]
ConnectionhasbeenmadetotheDatabase
√ Is there anything in the database (117ms)
POST/add-submission
POST /add-submission 200 1106.255 ms - 43
√ should add a new member (1139ms)
POST /add-submission 401 11.096 ms - 1571
√ should return error new member not added and a 400 error
PUT /update-submission/:id
(node:12004) DeprecationWarning: collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.
PUT /update-submission/5be0ac62fb6fc061430eb239 200 569.077 ms - 21
√ should update one submission in database (575ms)
Get/listOneSubmission/:id
GET /listOneSubmission/5be0ac62fb6fc061430eb239 200 327.217 ms - 26
√ should find one submission by id (332ms)
GET /listSubmissions/00000000080000 404 20.980 ms - 41
√ should return an error message and a 404 error
DELETE /delete-submission/:id
DELETE /delete-submission/5be0ac62fb6fc061430eb239 200 243.456 ms - 23
√ should delete (250ms)
DELETE /delete-submission/5be0ac62fb6fc06143 200 2.396 ms - 278
√ should return an error message and a 400 error
8 passing (5s)
➥
=============================== Coverage summary ===============================
Statements : 62.5% ( 120/192 )
Branches : 21.05% ( 8/38 )
Functions : 31.43% ( 11/35 )
Lines : 62.83% ( 120/191 )
================================================================================
The command "npm run coverage" exited with 0.
// Custom Routes
//gets
app.get('/listSubmissions', subs.displayAll);
app.get('/listOneSubmission/:id', subs.findSubmissionById);
app.get('/findByLocation/:location', subs.findByLocation);
//posts
app.post('/add-submission',subs.addSubmissions);
//puts
app.put('/update-submission/:id',subs.updateSubmission);
//deletes
app.delete('/delete-submission/:id',subs.deleteSubmission);
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
# run unit tests
npm run unit
# run e2e tests
npm run e2e
# run all tests
npm test
For a detailed explanation on how things work, check out the guide and docs for vue-loader.