it('enrich one activity', function() { var self = this; var tweet = new Tweet(); tweet.text = 'test'; tweet.actor = this.actor; return tweet.save .promisify(tweet) .then(function() { return tweet.populate.promisify(tweet, 'actor'); }) .then(function(tweet) { var activity = tweet.createActivity(); backend.serializeActivities([activity]); activity = JSON.parse(JSON.stringify(activity)); return backend.enrichActivities([activity]); }) .then(function(enriched) { enriched.should.length(1); enriched[0].should.have.property('actor'); enriched[0]['actor'].should.have.property('_id', self.actor._id); enriched[0].should.have.property('foreign_id', 'Tweet:' + tweet._id); }); });
it('custom fields enrichment', function() { var self = this; var tweet = new Tweet(); tweet.text = 'test'; tweet.bg = 'bgvalue'; tweet.actor = this.actor; tweet.link = this.link; return tweet.save .promisify(tweet) .then(function() { return tweet.populate.promisify(tweet, ['actor', 'link']); }) .then(function(tweet) { var activity = tweet.createActivity(); return backend.enrichActivities([activity]); }) .then(function(enriched) { enriched.should.length(1); enriched[0].should.have.property('actor'); enriched[0]['actor'].should.have.property('_id', self.actor._id); enriched[0].should.have.property('object'); enriched[0]['object'].should.have.property('_id', tweet._id); enriched[0]['object'].should.have.property('text', tweet.text); enriched[0].should.have.property('bg', 'bgvalue'); enriched[0].should.have.property('link'); enriched[0]['link'].should.have.property('_id', self.link._id); }); });