Fix jasmine specs so that they fail when they're supposed to.

This commit is contained in:
Sarah Mei 2010-12-12 12:57:11 -08:00
parent f2719e4c94
commit 7cd8e0f16b
3 changed files with 16 additions and 11 deletions

View file

@ -17,7 +17,9 @@ describe("Stream", function() {
describe("toggleComments", function() {
beforeEach(function() {
jasmine.Clock.useMock();
$('#jasmine_content').html(
'<div class="stream">' +
'<li class="message" data-guid="4ceef7ba2367bc2e4d0001e9">' +
'<div class="content">' +
'<div class="info">' +
@ -38,21 +40,23 @@ describe("Stream", function() {
'</li>' +
'</ul>' +
'</div>' +
'</li>'
'</li>' +
'</div>'
);
Stream.initialize();
});
it("toggles class hidden on the comment block", function () {
expect($('ul.comments')).toHaveClass("hidden");
$("a.show_post_comments").click();
setTimeout(function() {
expect($('ul.comments')).not.toHaveClass("hidden");
}, 250);
jasmine.Clock.tick(200);
expect($('ul.comments')).not.toHaveClass("hidden");
});
it("changes the text on the show comments link", function() {
$("a.show_post_comments").click();
setTimeout(function() {
expect($("a.show_post_comments").text()).toEqual("hide comments (0)");
}, 250);
jasmine.Clock.tick(200);
expect($("a.show_post_comments").text()).toEqual("hide comments (0)");
})
});
});

View file

@ -15,6 +15,7 @@ src_files:
- public/javascripts/vendor/jquery-ui-1.8.6.custom.min.js
- public/javascripts/vendor/jquery.tipsy.js
- public/javascripts/vendor/jquery.infieldlabel.js
- public/javascripts/vendor/jquery.autoresize.min.js
- public/javascripts/vendor/fancybox/jquery.fancybox-1.3.1.pack.js
- public/javascripts/diaspora.js
- public/javascripts/mobile.js

View file

@ -23,6 +23,7 @@ describe("View", function() {
describe("debug", function() {
describe("click", function() {
beforeEach(function() {
jasmine.Clock.useMock();
$("#jasmine_content").html(
'<div id="debug_info">' +
'<h5>DEBUG INFO</h5>' +
@ -37,10 +38,9 @@ describe("View", function() {
spyOn(View.debug, "click");
View.initialize();
$(View.debug.selector).click();
jasmine.Clock.tick(200);
expect(View.debug.click).toHaveBeenCalled();
setTimeout(function() {
expect($(View.debug.selector).css("display")).toEqual("block");
}, 500);
expect($(View.debug.selector).css("display")).toEqual("block");
});
});
});
@ -115,7 +115,7 @@ describe("View", function() {
View.initialize();
$(View.publisher.selector).focus();
var event = $.Event("keydown");
var event.ShiftKey = true;
event.ShiftKey = true;
event.keyCode = 13;
$(View.publisher.selector).trigger(event);
expect($.fn.submit).toHaveBeenCalled();