Doppia modalità di Registrazione con lista extra utenti
This commit is contained in:
@@ -80,7 +80,7 @@ const userjson = JSON.stringify(users[0]);
|
||||
|
||||
const todos = [{
|
||||
_id: new ObjectID(),
|
||||
category: "personal",
|
||||
// category: "personal",
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
@@ -96,7 +96,7 @@ const todos = [{
|
||||
userId: users[0]._id
|
||||
}, {
|
||||
_id: new ObjectID(),
|
||||
category: "personal",
|
||||
// category: "personal",
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
@@ -112,7 +112,7 @@ const todos = [{
|
||||
userId: users[0]._id
|
||||
}, {
|
||||
_id: new ObjectID(),
|
||||
category: "personal",
|
||||
// category: "personal",
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
@@ -127,7 +127,7 @@ const todos = [{
|
||||
progress: 0,
|
||||
}, { // RECORD CHE VERRA' UTILIZZATO PER AGGIUNGERE UN NUOVO TASK
|
||||
_id: new ObjectID(),
|
||||
category: "personal",
|
||||
// category: "personal",
|
||||
statustodo: 0,
|
||||
completed_at: new Date(),
|
||||
created_at: new Date(),
|
||||
@@ -148,8 +148,8 @@ const populateTodos = (done) => {
|
||||
Todo.deleteMany({})
|
||||
.then(() => {
|
||||
|
||||
var TodoOne = new Todo(todos[0]).save();
|
||||
var TodoTwo = new Todo(todos[1]).save();
|
||||
const TodoOne = new Todo(todos[0]).save();
|
||||
const TodoTwo = new Todo(todos[1]).save();
|
||||
|
||||
return Promise.all([TodoOne, TodoTwo])
|
||||
}).then(() => {
|
||||
|
||||
@@ -58,7 +58,7 @@ if (testsingolo) {
|
||||
})
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
expect(res.headers['x-auth']).toExist();
|
||||
expect(res.headers['x-auth']).toBeTruthy();
|
||||
})
|
||||
.end((err, res) => {
|
||||
if (err) {
|
||||
@@ -66,7 +66,7 @@ if (testsingolo) {
|
||||
}
|
||||
|
||||
User.findById(users[0]._id).then((user) => {
|
||||
expect(user.tokens[0]).toInclude({
|
||||
expect(user.tokens[0]).toContain({
|
||||
access: 'auth',
|
||||
// token: res.headers['x-auth'],
|
||||
date_login: date_login
|
||||
@@ -86,8 +86,8 @@ if (testsingolo) {
|
||||
.send(users[IndexUserToCreate])
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
expect(res.headers['x-auth']).toExist();
|
||||
expect(res.body._id).toExist();
|
||||
expect(res.headers['x-auth']).toBeTruthy();
|
||||
expect(res.body._id).toBeTruthy();
|
||||
expect(res.body.email).toBe(users[IndexUserToCreate].email);
|
||||
expect(res.body.username).toBe(users[IndexUserToCreate].username);
|
||||
expect(res.body.name).toBe(users[IndexUserToCreate].name);
|
||||
@@ -100,7 +100,7 @@ if (testsingolo) {
|
||||
}
|
||||
|
||||
User.findOne({ email: users[IndexUserToCreate].email }).then((user) => {
|
||||
expect(user).toExist();
|
||||
expect(user).toBeTruthy();
|
||||
done();
|
||||
}).catch((e) => done(e));
|
||||
});
|
||||
@@ -126,10 +126,10 @@ if (testsingolo) {
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /users/myusername', () => {
|
||||
describe('GET /users/idapp/myusername', () => {
|
||||
it('should return 200 if myusername exist', (done) => {
|
||||
request(app)
|
||||
.get('/users/' + users[0].username)
|
||||
.get('/users/' + users[0].idapp + '/' + users[0].username)
|
||||
// .set('x-auth', users[0].tokens[0].token)
|
||||
.expect(200)
|
||||
.end(done);
|
||||
@@ -137,7 +137,7 @@ if (testsingolo) {
|
||||
|
||||
it('should return 404 if myusername doesn\'t exist', (done) => {
|
||||
request(app)
|
||||
.get('/users/' + users[0].username + 'pippo')
|
||||
.get('/users/' + users[0].idapp + '/' + users[0].username + 'pippo')
|
||||
.expect(404)
|
||||
.end(done);
|
||||
});
|
||||
@@ -157,7 +157,7 @@ if (testsingolo) {
|
||||
})
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
expect(res.headers['x-auth']).toExist();
|
||||
expect(res.headers['x-auth']).toBeTruthy();
|
||||
})
|
||||
.end((err, res) => {
|
||||
if (err) {
|
||||
@@ -165,10 +165,12 @@ if (testsingolo) {
|
||||
}
|
||||
|
||||
User.findById(users[0]._id).then((user) => {
|
||||
expect(user.tokens[0]).toInclude({
|
||||
expect(user.tokens[0]).toContain({
|
||||
_id: user.tokens[0]._id,
|
||||
access: 'auth',
|
||||
// token: res.headers['x-auth'],
|
||||
date_login: date_login
|
||||
browser: useragent,
|
||||
date_login: date_login,
|
||||
token: users[0].tokens[0].token,
|
||||
});
|
||||
done();
|
||||
}).catch((e) => done(e));
|
||||
@@ -184,7 +186,7 @@ if (testsingolo) {
|
||||
})
|
||||
.expect(400)
|
||||
.expect((res) => {
|
||||
expect(res.headers['x-auth']).toNotExist();
|
||||
expect(res.headers['x-auth']).not.toBeTruthy();
|
||||
})
|
||||
.end((err, res) => {
|
||||
if (err) {
|
||||
@@ -208,7 +210,7 @@ if (testsingolo) {
|
||||
.send()
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
expect(res.headers['x-auth']).toNotExist();
|
||||
expect(res.headers['x-auth']).not.toBeTruthy();
|
||||
})
|
||||
.end((err, res) => {
|
||||
if (err) {
|
||||
@@ -291,7 +293,7 @@ if (testsingolo) {
|
||||
describe('GET /todos', () => {
|
||||
it('should get all todos', (done) => {
|
||||
request(app)
|
||||
.get(`/todos/${users[0]._id }`)
|
||||
.get(`/todos/`)
|
||||
.set('x-auth', users[0].tokens[0].token)
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
@@ -309,8 +311,8 @@ if (testsingolo) {
|
||||
.set('x-auth', users[0].tokens[0].token)
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
let miores = res
|
||||
let miadescr = miores.body.todos[0].descr
|
||||
let miores = res;
|
||||
let miadescr = miores.body.todos[0].descr;
|
||||
expect(res.body.todos.length).toBe(2);
|
||||
expect(miadescr).toBe(todos[0].descr);
|
||||
})
|
||||
@@ -365,7 +367,7 @@ if (testsingolo) {
|
||||
}
|
||||
|
||||
Todo.findById(hexId).then((todo) => {
|
||||
expect(todo).toNotExist();
|
||||
expect(todo).not.toBeTruthy();
|
||||
done();
|
||||
}).catch((e) => done(e));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user