mirror of
https://github.com/wassname/talk.git
synced 2026-08-14 12:50:17 +08:00
Merge branch 'master' into ban-user
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user