Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should append to activity item corresponding entry data and remove entry_id, entry_table', () => {
return db.one(
`SELECT id, created_at, action, entry_id, entry_table
FROM activity WHERE id = 1`
)
.then(activityItem => {
return Activity._transformActivityItem(activityItem);
})
.then(transformed => {
assert.property(transformed, 'created_at');
assert.deepEqual(_.omit(transformed, ['created_at']), {
id: 1,
action: 'Updated',
type: 'card',
entry: {
title: 'test card',
link: `/boards/${boardId}/cards/${cardId}`,
},
.then(() => db.one('SELECT id, title FROM boards WHERE id = 2'))
.then(updatedBoard => assert.deepEqual(updatedBoard, {
.then(list => {
return db.one(
'SELECT board_id FROM boards_lists WHERE list_id = $1',
[list.id]
);
})
.then(result => {
.then(() => db.one('SELECT * from test_1 WHERE id = 2'))
.then(entry => {
.then(comment => {
return db.one(
`SELECT card_id FROM cards_comments WHERE comment_id = $1`,
[comment.id]
);
})
.then(result => {
return authenticate().then(request => {
return db.one(`SELECT id FROM users`)
.then(({ id }) => {
return db.none(
`INSERT INTO boards(id, title, deleted)
VALUES ($2, 'test board 1', $4), ($3, 'test board 2', null);
INSERT INTO users_boards VALUES ($1, $2), ($1, $3)`,
[id, boardId, board2Id, now]
);
})
.then(() => request);
});
}
.end((err, res) => {
if (err) { done(err); }
assert.equal(res.body.success, true);
db.one('SELECT * FROM boards WHERE id = $1', [boardId])
.then(board => {
assert.deepEqual(board.lists, [1]);
})
.then(() => {
const promise = db.one('SELECT * FROM lists WHERE id = $1', [listId]);
return expect(promise).to.be.rejectedWith(/No data returned from the query/);
})
.then(done, done);
});
});
.then(() => db.one('SELECT board_id, list_id FROM boards_lists WHERE board_id = 2'))
.then(entry => assert.deepEqual(entry, { board_id: 2, list_id: 1 }));
.end((err, res) => {
if (err) { done(err); }
assert.equal(res.body.success, true);
const listId = res.body.data.listId;
db.one('SELECT * FROM lists WHERE id = $1', [listId])
.then(list => assert.equal(list.title, listTitle))
.then(() => db.one('SELECT * FROM boards WHERE id = $1', [boardId]))
.then(board => {
assert.include(board.lists, listId);
})
.then(done, done);
});
});
.then(() => {
const promise = db.one('SELECT * FROM cards WHERE id = $1', [cardId]);
return expect(promise).to.be.rejectedWith(/No data returned from the query/);
})
.then(done, done);