/
ScrollerTests.js
49 lines (40 loc) · 2.07 KB
/
ScrollerTests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
Copyright 2008-2009 University of California, Berkeley
Copyright 2008-2009 University of Toronto
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://source.fluidproject.org/svn/LICENSE.txt
*/
(function ($) {
$(document).ready (function () {
var container = function () {
return $("#scrollableWithWrapper");
};
var outerWrapper = function () {
return $("#outer");
};
var scrollerTests = new jqUnit.TestCase("Vertical Scroller Tests");
scrollerTests.test("Setup", function () {
var scroller = fluid.scroller("#scrollableWithWrapper");
jqUnit.assertNotUndefined("A scroller instance should have been returned.", scroller);
jqUnit.assertEquals("The scroller should have the correct container.",
container()[0], scroller.container[0]);
jqUnit.assertEquals("The scroller should have the correct outer wrapper.",
outerWrapper()[0], scroller.scrollingElm[0]);
});
scrollerTests.test("Error when necessary DOM structure is not found.", function () {
// At the moment, Scroller expects there to be two wrapping elements around the scrollable container.
// If these aren't specified we should get an error.
try {
var scroller = fluid.scroller("#scrollableNoWrapper");
jqUnit.fail("An exception should be thrown when no scroller wrapper is present.");
} catch (e) {
jqUnit.assertNotUndefined("An exception should be thrown when no scroller wrapper is present.", e);
}
jqUnit.assertUndefined("If the container isn't wrapped in a scroller element, scroller creation should fail.",
scroller);
});
});
})(jQuery);