Visitar URL original
Open story in background tab when clicked with metaKey. by gaynetdinov · Pull Request #230 · stringer-rss/stringer · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added some test examples for handling click on story.
  • Loading branch information
Damir Gaynetdinov
Damir Gaynetdinov committed Jul 24, 2013
commit df0ca6c657d60077ad2d24f380851e2b71c5356a
2 changes: 1 addition & 1 deletion app/public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ var AppView = Backbone.View.extend({

render: function() {
var unreadCount = this.stories.unreadCount();

if (unreadCount === 0) {
document.title = window.i18n.titleName;
} else {
Expand Down
38 changes: 35 additions & 3 deletions spec/javascript/spec/views/story_view_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("Storyiew", function(){
this.story.set("keep_unread", true);
this.view.render();

assertTagExists(this.view.$el, ".story-keep-unread .icon-check");
assertTagExists(this.view.$el, ".story-keep-unread .icon-check");
});

it("should render two instances of the star button", function(){
Expand All @@ -101,7 +101,39 @@ describe("Storyiew", function(){
this.story.set("is_starred", true);
this.view.render();

assertTagExists(this.view.$el, ".story-starred .icon-star", 2);
assertTagExists(this.view.$el, ".story-starred .icon-star", 2);
});

describe("Handling click on story", function(){
beforeEach(function() {
this.toggle_stub = sinon.stub(this.story, "toggle");
});

afterEach(function() {
this.toggle_stub.restore();
});

it("should call toggle() method when clicked on story", function(){
this.view.$('.story-preview').click();
this.toggle_stub.should.have.been.calledOnce;
});

it("should not call toggle() method when clicked on story with metaKey pressed", function(){
var e = jQuery.Event("click");
e.metaKey = true;
this.view.$('.story-preview').trigger(e);

this.toggle_stub.should.not.have.been.calledOnce;
});

it("should not call toggle() method when clicked on story with ctrlKey pressed", function(){
var e = jQuery.Event("click");
e.ctrlKey = true;
this.view.$('.story-preview').trigger(e);

this.toggle_stub.should.not.have.been.calledOnce;
});
});

});
});
});