TestCase("PluginTest", { testExistenceOfPlugin: function (){ assertTrue("scroll plugin", !!$.fn.scrollbar); } } ); TestCase("HtmlGeneratorTest", { setUp: function (){ var fixtures = jstestdriver.fixtures(); this.fixture_1 = fixtures.fixture_1; this.fixture_2 = fixtures.fixture_2; } , tearDown: function (){ delete this.fixture_1; delete this.fixture_2; } , testGenerationOfScrollbarHandle: function (){ assertEquals(0, _AN_Read_length("length", this.fixture_1.find('.scrollbar-handle'))); this.fixture_1.scrollbar(); assertEquals(1, _AN_Read_length('length', this.fixture_1.find('.scrollbar-handle'))); } , testGenerationOfNoScrollbar: function (){ this.fixture_2.scrollbar(); assertEquals(0, _AN_Read_length('length', this.fixture_2.find('.scrollbar-handle'))); } , testFullVisibleContentContainer: function (){ var contentHeight = $.fn.scrollbar.contentHeight(this.fixture_2); this.fixture_2.scrollbar({ containerHeight: contentHeight + 1} ); assertEquals(0, _AN_Read_length('length', this.fixture_2.find('.scrollbar-handle'))); } , testOverflowedContentContainer: function (){ var contentHeight = $.fn.scrollbar.contentHeight(this.fixture_2); this.fixture_2.scrollbar({ containerHeight: contentHeight - 1} ); assertEquals(1, _AN_Read_length('length', this.fixture_2.find('.scrollbar-handle'))); } , testHtmlStructureAfterMeassuringHeight: function (){ var before = this.fixture_2.html(); this.fixture_2.scrollbar(); var after = this.fixture_2.html(); assertEquals(before, after); } } ); TestCase("OptionsTest", { setUp: function (){ var fixtures = jstestdriver.fixtures(); this.fixture_1 = fixtures.fixture_1; this.fixture_2 = fixtures.fixture_2; } , tearDown: function (){ delete this.fixture_1; delete this.fixture_2; } , testFixedHandleHeight: function (){ this.fixture_1.scrollbar({ handleHeight: 20} ); assertEquals(20, this.fixture_1.find('.scrollbar-handle').height()); } , testMinimumHandleHeight: function (){ this.fixture_1.scrollbar({ handleMinHeight: 60} ); assertEquals("Minimum height of scrollbar handle", 60, this.fixture_1.find('.scrollbar-handle').height()); } , testAutoHandleHeight: function (){ var contentHeight = $.fn.scrollbar.contentHeight(this.fixture_2); this.fixture_2.scrollbar({ arrows: false , containerHeight: Math.ceil(contentHeight / 2), handleMinHeight: 0} ); var handleHeight = Math.ceil(contentHeight / 4); assertEquals("Actual height of scrollbar handle", handleHeight, this.fixture_2.find('.scrollbar-handle').height()); } , testScrollbarWithArrows: function (){ this.fixture_1.scrollbar({ arrows: true } ); assertEquals(1, _AN_Read_length('length', this.fixture_1.find('.scrollbar-handle-container'))); assertEquals(1, _AN_Read_length('length', this.fixture_1.find('.scrollbar-handle-up'))); assertEquals(1, _AN_Read_length('length', this.fixture_1.find('.scrollbar-handle-down'))); } , testScrollbarWithoutArrows: function (){ this.fixture_1.scrollbar({ arrows: false } ); assertEquals(1, _AN_Read_length('length', this.fixture_1.find('.scrollbar-handle-container'))); assertEquals(0, _AN_Read_length('length', this.fixture_1.find('.scrollbar-handle-up'))); assertEquals(0, _AN_Read_length('length', this.fixture_1.find('.scrollbar-handle-down'))); } } ); TestCase("RepaintTest", { setUp: function (){ var fixtures = jstestdriver.fixtures(); this.fixture_1 = fixtures.fixture_1; } , tearDown: function (){ delete this.fixture_1; } , testDoubleContentHandleHeight: function (){ var containerHeight = this.fixture_1.height(); var contentHeight = $.fn.scrollbar.contentHeight(this.fixture_1); this.fixture_1.scrollbar({ handleHeight: "auto", handleMinHeight: 0, arrows: false } ); var handleHeight = Math.ceil(containerHeight * containerHeight / contentHeight); this.fixture_1.find('.scrollbar-pane').children().clone().appendTo('.scrollbar-pane'); this.fixture_1.scrollbar("repaint"); assertEquals(Math.ceil(handleHeight / 2), this.fixture_1.find('.scrollbar-handle').height()); } , testDoubleContentHandlePosition: function (){ this.fixture_1.scrollbar({ handleHeight: "auto", handleMinHeight: 0, arrows: false } ); assertEquals('0px', this.fixture_1.find('.scrollbar-handle').css('top')); this.fixture_1.scrollbar("scrollto", 100); var top = this.fixture_1.find('.scrollbar-handle').css('top'); this.fixture_1.find('.scrollbar-pane').children().clone().appendTo('.scrollbar-pane'); this.fixture_1.scrollbar("repaint"); assertTrue(this.fixture_1.find('.scrollbar-handle').css('top') < top); } } );