Merge branch 'master' into ban-user

This commit is contained in:
gaba
2016-11-22 09:35:06 -08:00
16 changed files with 154 additions and 74 deletions
+9 -8
View File
@@ -10,10 +10,6 @@ describe('Action: models', () => {
action_type: 'flag',
item_id: '123',
item_type: 'comments'
}, {
action_type: 'like',
item_id: '789',
item_type: 'comments'
}, {
action_type: 'flag',
item_id: '456',
@@ -22,6 +18,10 @@ describe('Action: models', () => {
action_type: 'flag',
item_id: '123',
item_type: 'comments'
}, {
action_type: 'like',
item_id: '123',
item_type: 'comments'
}]).then((actions) => {
mockActions = actions;
});
@@ -39,7 +39,7 @@ describe('Action: models', () => {
describe('#findByItemIdArray()', () => {
it('should find an array of actions from an array of item_ids', () => {
return Action.findByItemIdArray(['123', '456']).then((result) => {
expect(result).to.have.length(3);
expect(result).to.have.length(4);
});
});
});
@@ -48,16 +48,17 @@ describe('Action: models', () => {
it('should return properly formatted summaries from an array of item_ids', () => {
return Action.getActionSummaries(['123', '789']).then((result) => {
expect(result).to.have.length(2);
const sorted = result.sort((a, b) => a.count - b.count);
delete sorted[0].id;
delete sorted[1].id;
expect(sorted[0]).to.deep.equal({
action_type: 'like',
count: 1,
item_id: '789',
item_id: '123',
item_type: 'comments',
current_user: false
});
expect(sorted[1]).to.deep.equal({
action_type: 'flag',
count: 2,
+16
View File
@@ -44,6 +44,22 @@ describe('User: models', () => {
});
});
describe('#findPublicByIdArray()', () => {
it('should find an array of users from an array of ids', () => {
const ids = mockUsers.map((user) => user.id);
return User.findPublicByIdArray(ids).then((result) => {
expect(result).to.have.length(3);
const sorted = result.sort((a, b) => {
if(a.displayName < b.displayName) {return -1;}
if(a.displayName > b.displayName) {return 1;}
return 0;
});
expect(sorted[0]).to.have.property('displayName')
.and.to.equal('Marvel');
});
});
});
describe('#findLocalUser', () => {
it('should find a user when we give the right credentials', () => {