Fixed tests for new users model

This commit is contained in:
Wyatt Johnson
2016-11-09 16:33:19 -07:00
parent 42a7eee1a2
commit 27896b8e42
2 changed files with 23 additions and 20 deletions
@@ -42,7 +42,7 @@ Promise.all([fetch('/api/v1/comments/status/pending'), fetch('/api/v1/comments/s
// Update a comment. Now to update a comment we need to send back the whole object
const updateComment = (store, comment) =>
fetch('/api/v1/comments/${comment._id}/status', {
fetch(`/api/v1/comments/${comment._id}/status`, {
method: 'POST',
body: JSON.stringify({status: comment.status})
})
+22 -19
View File
@@ -34,11 +34,13 @@ describe('Comment: models', () => {
}];
const users = [{
id: '123',
display_name: 'Ana',
email: 'stampi@gmail.com',
displayName: 'Stampi',
password: '1Coral!'
}, {
id: '456',
display_name: 'Maria',
email: 'sockmonster@gmail.com',
displayName: 'Sockmonster',
password: '2Coral!'
}];
const actions = [{
@@ -54,13 +56,12 @@ describe('Comment: models', () => {
}];
beforeEach(() => {
return Setting.create(settings).then(() => {
return Comment.create(comments);
}).then(() => {
return User.create(users);
}).then(() => {
return Action.create(actions);
});
return Promise.all([
Setting.create(settings),
Comment.create(comments),
User.createLocalUsers(users),
Action.create(actions)
]);
});
describe('#findById()', () => {
@@ -74,15 +75,17 @@ describe('Comment: models', () => {
describe('#findByAssetId()', () => {
it('should find an array of comments by asset id', () => {
return Comment.findByAssetId('123').then((result) => {
expect(result).to.have.length(2);
result.sort((a, b) => {
if (a.body < b.body) {return -1;}
else {return 1;}
return Comment
.findByAssetId('123')
.then((result) => {
expect(result).to.have.length(2);
result.sort((a, b) => {
if (a.body < b.body) {return -1;}
else {return 1;}
});
expect(result[0]).to.have.property('body', 'comment 10');
expect(result[1]).to.have.property('body', 'comment 20');
});
expect(result[0]).to.have.property('body', 'comment 10');
expect(result[1]).to.have.property('body', 'comment 20');
});
});
});
describe('#moderationQueue()', () => {