/* Copyright (c) 2010, Diaspora Inc. This file is * licensed under the Affero General Public License version 3 or later. See * the COPYRIGHT file. */ describe("Stream", function() { describe("initialize", function() { it("attaches a click event to show_post_comments links", function() { spyOn($.fn, "delegate"); Stream.initialize(); expect($.fn.delegate).toHaveBeenCalledWith( "a.show_post_comments", "click", Stream.toggleComments); }); }); describe("toggleComments", function() { beforeEach(function() { jasmine.Clock.useMock(); $('#jasmine_content').html( '
' + '
  • ' + '
    ' + '' + '' + '
    ' + '
  • ' + '
    ' ); Stream.initialize(); }); it("toggles class hidden on the comment block", function () { expect($('ul.comments')).toHaveClass("hidden"); $("a.show_post_comments").click(); 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(); jasmine.Clock.tick(200); expect($("a.show_post_comments").text()).toEqual("hide comments (0)"); }) }); });