Expecting stream endpoint to return items broken out by type.

This commit is contained in:
David Jay
2016-11-08 17:53:38 -05:00
parent e8584b499b
commit d7ead01180
2 changed files with 12 additions and 3 deletions
+10 -3
View File
@@ -89,12 +89,19 @@ export function getStream (assetId) {
)
.then((json) => {
/* Add items to the store */
const itemTypes = Object.keys(json);
for (let i=0; i < itemTypes.length; i++ ) {
for (var j=0; j < json[itemTypes[i]].length; j++ ) {
dispatch(addItem(json[itemTypes[i]][j]));
}
}
/* Sort comments by date*/
let rootComments = []
let childComments = {}
json.sort((a,b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())
json.reduce((prev, item) => {
dispatch(addItem(item))
json.comments.sort((a,b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())
json.comments.reduce((prev, item) => {
/* Check for root and child comments. */
if (
+2
View File
@@ -45,6 +45,8 @@ describe('Action: models', () => {
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({
type: 'like',
count: 1,