Disabled debug Mongoose
Updated modules fixed tests
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
const { ObjectID } = require('mongodb');
|
||||
const {ObjectID} = require('mongodb');
|
||||
const jwt = require('jsonwebtoken');
|
||||
|
||||
const { Todo } = require('../../models/todo');
|
||||
const { User } = require('../../models/user');
|
||||
const {Todo} = require('../../models/todo');
|
||||
const {User} = require('../../models/user');
|
||||
|
||||
var bcrypt = require('bcryptjs');
|
||||
|
||||
@@ -20,49 +20,54 @@ const userTwoId = new ObjectID();
|
||||
// });
|
||||
// String(mypwdcrypt)
|
||||
|
||||
|
||||
let mypwdchiaro = 'mypassword@1A';
|
||||
let mypwdcrypted = '$2b$12$mteST.isuWO0SNsfeZ0aCe.Dz3qwPh5SU8t9rc5SaPTkb3j0ywGv6'
|
||||
let mypwdcrypted = '$2b$12$mteST.isuWO0SNsfeZ0aCe.Dz3qwPh5SU8t9rc5SaPTkb3j0ywGv6';
|
||||
|
||||
const date_login = new Date();
|
||||
|
||||
// const useragent = "auth Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36"
|
||||
const useragent = "node-superagent/2.3.0";
|
||||
const useragent = 'node-superagent/2.3.0';
|
||||
|
||||
const users = [{
|
||||
_id: userOneId,
|
||||
keyappid: process.env.KEY_APP_ID,
|
||||
lang: 'it',
|
||||
idapp: '1',
|
||||
email: 'paoloa.rena77@gmail.com',
|
||||
username: 'paoloar77B',
|
||||
name: 'Paolo',
|
||||
surname: 'Arena',
|
||||
password: mypwdcrypted,
|
||||
tokens: [{
|
||||
access: 'auth',
|
||||
browser: useragent,
|
||||
token: jwt.sign({ _id: userOneId, access: 'auth' }, process.env.SIGNCODE).toString(),
|
||||
date_login
|
||||
}]
|
||||
},
|
||||
const users = [
|
||||
{
|
||||
_id: userOneId,
|
||||
keyappid: process.env.KEY_APP_ID,
|
||||
lang: 'it',
|
||||
idapp: '1',
|
||||
email: 'paoloa.rena77@gmail.com',
|
||||
username: 'paoloar77B',
|
||||
name: 'Paolo',
|
||||
surname: 'Arena',
|
||||
password: mypwdcrypted,
|
||||
tokens: [
|
||||
{
|
||||
access: 'auth',
|
||||
browser: useragent,
|
||||
token: jwt.sign({_id: userOneId, access: 'auth'}, process.env.SIGNCODE).
|
||||
toString(),
|
||||
date_login,
|
||||
}],
|
||||
},
|
||||
{
|
||||
_id: userTwoId,
|
||||
keyappid: process.env.KEY_APP_ID,
|
||||
lang: 'it',
|
||||
idapp: '1',
|
||||
email: 'pa@com',
|
||||
email: 'patesttest@com',
|
||||
name: 'Paolo2',
|
||||
surname: 'Arena2',
|
||||
password: mypwdcrypted,
|
||||
username: 'paoloar77C',
|
||||
tokens: [{
|
||||
access: 'auth',
|
||||
browser: useragent,
|
||||
token: jwt.sign({ _id: userTwoId, access: 'auth' }, process.env.SIGNCODE).toString(),
|
||||
date_login
|
||||
}]
|
||||
}, {
|
||||
tokens: [
|
||||
{
|
||||
access: 'auth',
|
||||
browser: useragent,
|
||||
token: jwt.sign({_id: userTwoId, access: 'auth'}, process.env.SIGNCODE).
|
||||
toString(),
|
||||
date_login,
|
||||
}],
|
||||
},
|
||||
{
|
||||
keyappid: process.env.KEY_APP_ID, // RECORD CHE VERRA' UTILIZZATO PER UNA NUOVA REGISTRAZIONE
|
||||
lang: 'it',
|
||||
idapp: '1',
|
||||
@@ -77,101 +82,117 @@ const userjson = JSON.stringify(users[0]);
|
||||
|
||||
// console.log('userjson=', userjson)
|
||||
|
||||
const mynewID = new ObjectID();
|
||||
|
||||
const todos = [{
|
||||
_id: new ObjectID(),
|
||||
// category: "personal",
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
descr: "Primo Task Esempio",
|
||||
enableExpiring: false,
|
||||
expiring_at: new Date(),
|
||||
modified: false,
|
||||
modify_at: new Date(),
|
||||
pos: 1,
|
||||
priority: 1,
|
||||
progress: 0,
|
||||
userId: users[0]._id
|
||||
}, {
|
||||
_id: new ObjectID(),
|
||||
// category: "personal",
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
descr: "Secondo Task Esempio",
|
||||
enableExpiring: false,
|
||||
expiring_at: new Date(),
|
||||
modified: false,
|
||||
modify_at: new Date(),
|
||||
pos: 2,
|
||||
priority: 1,
|
||||
progress: 0,
|
||||
userId: users[0]._id
|
||||
}, {
|
||||
_id: new ObjectID(),
|
||||
// category: "personal",
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
descr: "Terzo Task Esempio",
|
||||
enableExpiring: false,
|
||||
expiring_at: new Date(),
|
||||
modified: false,
|
||||
modify_at: new Date(),
|
||||
pos: 3,
|
||||
priority: 1,
|
||||
progress: 0,
|
||||
}, { // RECORD CHE VERRA' UTILIZZATO PER AGGIUNGERE UN NUOVO TASK
|
||||
_id: new ObjectID(),
|
||||
// category: "personal",
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
descr: "Nuovo Quarto Task Esempio da Inserire",
|
||||
enableExpiring: false,
|
||||
expiring_at: new Date(),
|
||||
modified: false,
|
||||
modify_at: new Date(),
|
||||
pos: 4,
|
||||
priority: 1,
|
||||
progress: 0,
|
||||
userId: users[0]._id
|
||||
}];
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
|
||||
const populateTodos = (done) => {
|
||||
var ObjectId = mongoose.Types.ObjectId;
|
||||
|
||||
Todo.deleteMany({})
|
||||
.then(() => {
|
||||
const todos = [
|
||||
{
|
||||
_id: mynewID,
|
||||
category: ObjectId(),
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
// category: "personal",
|
||||
descr: 'Primo Task Esempio',
|
||||
enableExpiring: false,
|
||||
expiring_at: new Date(),
|
||||
modified: false,
|
||||
modify_at: new Date(),
|
||||
pos: 1,
|
||||
priority: 1,
|
||||
progress: 0,
|
||||
userId: users[0]._id,
|
||||
}, {
|
||||
_id: new ObjectID(),
|
||||
category: ObjectId(mynewID),
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
descr: 'Secondo Task Esempio',
|
||||
enableExpiring: false,
|
||||
expiring_at: new Date(),
|
||||
modified: false,
|
||||
modify_at: new Date(),
|
||||
pos: 2,
|
||||
priority: 1,
|
||||
progress: 0,
|
||||
userId: users[1]._id,
|
||||
}, {
|
||||
_id: new ObjectID(),
|
||||
category: ObjectId(mynewID),
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
descr: 'Terzo Task Esempio',
|
||||
enableExpiring: false,
|
||||
expiring_at: new Date(),
|
||||
modified: false,
|
||||
modify_at: new Date(),
|
||||
pos: 3,
|
||||
priority: 1,
|
||||
progress: 0,
|
||||
userId: users[2]._id,
|
||||
}, { // RECORD CHE VERRA' UTILIZZATO PER AGGIUNGERE UN NUOVO TASK
|
||||
_id: new ObjectID(),
|
||||
category: ObjectId(mynewID),
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
descr: 'Nuovo Quarto Task Esempio da Inserire',
|
||||
enableExpiring: false,
|
||||
expiring_at: new Date(),
|
||||
modified: false,
|
||||
modify_at: new Date(),
|
||||
pos: 4,
|
||||
priority: 1,
|
||||
progress: 0,
|
||||
userId: users[0]._id,
|
||||
}];
|
||||
|
||||
const TodoOne = new Todo(todos[0]).save();
|
||||
const TodoTwo = new Todo(todos[1]).save();
|
||||
|
||||
return Promise.all([TodoOne, TodoTwo])
|
||||
}).then(() => {
|
||||
done()
|
||||
|
||||
// tools.mylogshow('todos[0]', todos[0]._id);
|
||||
// tools.mylogshow('todos[1]', todos[1]._id);
|
||||
const populateTodos = async (done) => {
|
||||
|
||||
// console.log(' delete Todos...')
|
||||
await Todo.deleteMany({}).then(() => {
|
||||
// console.log(' deleted ...')
|
||||
const TodoOne = new Todo(todos[0]).save();
|
||||
const TodoTwo = new Todo(todos[1]).save();
|
||||
|
||||
return Promise.all([TodoOne, TodoTwo]);
|
||||
}).then(() => {
|
||||
// console.log('populateTodos done !')
|
||||
// done()
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
const populateUsers = async (done) => {
|
||||
|
||||
const populateUsers = (done) => {
|
||||
// console.log(' delete Users ...')
|
||||
await User.deleteMany({}).then(() => {
|
||||
|
||||
User.deleteMany({})
|
||||
.then(() => {
|
||||
// console.log(' deleted ...')
|
||||
// console.log('users[0]', users[0])
|
||||
var userOne = new User(users[0]).save();
|
||||
var userTwo = new User(users[1]).save();
|
||||
|
||||
// console.log('users[0]', users[0])
|
||||
var userOne = new User(users[0]).save();
|
||||
var userTwo = new User(users[1]).save();
|
||||
|
||||
return Promise.all([userOne, userTwo])
|
||||
}).then(() => done());
|
||||
return Promise.all([userOne, userTwo]);
|
||||
}).then(() => {
|
||||
// console.log('populateUsers done !')
|
||||
// done()
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
module.exports = { todos, populateTodos, users, populateUsers, userjson, mypwdcrypted, mypwdchiaro, date_login };
|
||||
module.exports = {
|
||||
todos,
|
||||
populateTodos,
|
||||
users,
|
||||
populateUsers,
|
||||
userjson,
|
||||
mypwdcrypted,
|
||||
mypwdchiaro,
|
||||
date_login,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user