scrollview-list-unit-test.html revision d84d625d7d43624674286499b8a8e8fe785c83fc
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe<script type="text/javascript" src="/build/yui/yui-min.js"></script>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div id="scrollable1" class="yui3-scrollview-loading">
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div>I am a div with some LI content inside me!
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div>I am a div with some LI content inside me!
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div>I am a div with some LI content inside me!
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <h1>Scrollview 2 - has divs as immediate children</h1>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div id="scrollable2" class="yui3-scrollview-loading">
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div>I am a div with some LI content inside me!
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div>I am a div with some LI content inside me!
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe <div>I am a div with some LI content inside me!
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe(function() {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min',
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe allowRollup: false
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }).use("console", "test", "dump", "scrollview-base", 'scrollview-list', function(Y) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // Set up the page
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe var ASSERT = Y.Assert,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe var myConsole = new Y.Console().render();
6d8b5bf1bbeb8c7f1357b3e5836fe664fb0fcc46Richard Lowe var testBasic = new Y.Test.Case({
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe name: "API Tests",
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe contentBox: '#scrollable1',
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe height: 372,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe minDistance:0,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe minVelocity:0
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe contentBox: '#scrollable2',
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe height: 372,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe minDistance:0,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe minVelocity:0
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //---------------------------------------------
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // Setup and tear down
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //---------------------------------------------
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe setUp : function () {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe tearDown : function () {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //---------------------------------------------
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // Instantiation
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //---------------------------------------------
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //makes sure only immediate decendant LI and UL's are selected
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe testBasicScrollviewList: function() {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe cb, id, ul, li, className, special;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe cb = sv.get('contentBox');
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ul = Y.all('#'+ id +' > ul')
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe li = Y.all('#'+ id +' > ul > li');
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe special = Y.all('.special');
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ul.each(function(item) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe className = item.getAttribute('class');
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Y.log('checked ul');
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Y.Assert.areEqual("yui3-scrollview-list", className, "List Class name not equal");
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe li.each(function(item) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe className = item.getAttribute('class');
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Y.log('checked li');
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Y.Assert.areEqual("yui3-scrollview-item", className, "Item Class name not equal");
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe special.each(function(item) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Y.log('checked specials');
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Y.Assert.isFalse(item.hasClass('yui3-scrollview-item'), "Special LIs should not have class");
cb = sv.get('contentBox');
id = cb.get('id');
li = Y.all('#' + id + ' li');
li.each(function(item) {
Y.log('checked li');
Y.Assert.isFalse(item.hasClass('yui3-scrollview-item'), "these LIs should not have class because they are not immediate decendants");
var suite = new Y.Test.Suite({name:"Scrollview List Test Suite"});
suite.add(testBasic);
Y.Test.Runner.setName("Scrollview Test Runner");
Y.Test.Runner.add(suite);