Skip to content

Commit

Permalink
Merge pull request #394 from aholachek/show-rec
Browse files Browse the repository at this point in the history
uncommenting out recommender widget
  • Loading branch information
aholachek committed May 19, 2015
2 parents 0fdbcae + ccd70bb commit f702ad6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
12 changes: 4 additions & 8 deletions src/js/widgets/recommender/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,10 @@ define([

activate: function (beehive) {

/*
* hiding this widget for now
* */
//
// this.pubsub = beehive.Services.get('PubSub');
// _.bindAll(this, ['processResponse', 'onDisplayDocuments']);
// this.pubsub.subscribe(this.pubsub.DISPLAY_DOCUMENTS, this.onDisplayDocuments);
// this.pubsub.subscribe(this.pubsub.DELIVERING_RESPONSE, this.processResponse);
this.pubsub = beehive.Services.get('PubSub');
_.bindAll(this, ['processResponse', 'onDisplayDocuments']);
this.pubsub.subscribe(this.pubsub.DISPLAY_DOCUMENTS, this.onDisplayDocuments);
this.pubsub.subscribe(this.pubsub.DELIVERING_RESPONSE, this.processResponse);
},

onDisplayDocuments: function(apiQuery) {
Expand Down
48 changes: 24 additions & 24 deletions test/mocha/js/widgets/recommender_widget.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,30 @@ define([
expect(apiRequest.toJSON().target).to.eql('recommender/fakeBibcode');
});

// it("Communicates through pubsub", function() {
// var minsub = new (MinPubSub.extend({
// request: function(apiRequest) {
// return JSON.parse(JSON.stringify(testData));
// }
//
// }))({verbose: false});
//
// var widget = new RecommenderWidget();
// var onDisplayDocuments = sinon.spy(widget, 'onDisplayDocuments');
// var loadBibcodeData = sinon.spy(widget, 'loadBibcodeData');
// var processResponse = sinon.spy(widget, 'processResponse');
//
// widget.activate(minsub.beehive.getHardenedInstance());
//
// minsub.publish(minsub.DISPLAY_DOCUMENTS, minsub.createQuery({'q': 'bibcode:foo'}));
// expect(onDisplayDocuments.callCount).to.be.eql(1);
// expect(loadBibcodeData.callCount).to.be.eql(1);
// expect(loadBibcodeData.lastCall.args[0]).to.be.eql('foo');
// expect(processResponse.callCount).to.be.eql(1);
//
// expect(widget.collection.models.length).to.be.eql(7);
//
// });
it("Communicates through pubsub", function() {
var minsub = new (MinPubSub.extend({
request: function(apiRequest) {
return JSON.parse(JSON.stringify(testData));
}

}))({verbose: false});

var widget = new RecommenderWidget();
var onDisplayDocuments = sinon.spy(widget, 'onDisplayDocuments');
var loadBibcodeData = sinon.spy(widget, 'loadBibcodeData');
var processResponse = sinon.spy(widget, 'processResponse');

widget.activate(minsub.beehive.getHardenedInstance());

minsub.publish(minsub.DISPLAY_DOCUMENTS, minsub.createQuery({'q': 'bibcode:foo'}));
expect(onDisplayDocuments.callCount).to.be.eql(1);
expect(loadBibcodeData.callCount).to.be.eql(1);
expect(loadBibcodeData.lastCall.args[0]).to.be.eql('foo');
expect(processResponse.callCount).to.be.eql(1);

expect(widget.collection.models.length).to.be.eql(7);

});

})
});

0 comments on commit f702ad6

Please sign in to comment.