/*
 Overthrow unit tests - using qUnit
 */

window.onload = function(){

	var scroller, testElem;

	module( "properties", {
		setup: function(){
      testElem = document.querySelector( "#testelem" );
			scroller = testElem.querySelector( ".overthrow.sidescroll" );
			scroller.scrollLeft = 0;
			overthrow.sidescroller( [testElem], {fixedItemWidth: true} );
		}
	});

	function nextDisabled(){
		return testElem.querySelectorAll(".sidescroll-next.disabled");
	}

	function prevDisabled(){
		return testElem.querySelectorAll(".sidescroll-prev.disabled");
	}

	test( "only nav prev should be disabled initially", function() {
		var next, prev;

		prev = prevDisabled();
		equal( prev.length, 1 );

		next = nextDisabled();
		equal( next.length, 0 );
	});

	asyncTest( "nav next should be disabled after scroll", function() {
		var next;

		next = nextDisabled();
		equal( next.length, 0 );

		console.log( scroller );
		scroller.scrollLeft = 10000;

		setTimeout(function() {
			next = nextDisabled();

			equal( next.length, 1 );
			start();
		}, 500);
	});
};

@@ -106,18 +106,20 @@
 e( %22
-properties
+disabled nav
 %22, %7B
@@ -889,35 +889,8 @@
 );%0A%0A
-%09%09console.log( scroller );%0A
 %09%09sc
@@ -1025,12 +1025,496 @@
 0);%0A%09%7D);
+%0A%0A%09asyncTest( %22both should be active in center%22, function() %7B%0A%09%09var next, prev;%0A%0A%09%09next = nextDisabled();%0A%09%09prev = prevDisabled();%0A%0A%09%09// check the default state%0A%09%09equal( next.length, 0 );%0A%09%09equal( prev.length, 1 );%0A%0A%09%09// move into the scrolling region%0A%09%09scroller.scrollLeft = 10;%0A%0A%09%09setTimeout(function() %7B%0A%09%09%09prev = prevDisabled();%0A%09%09%09next = nextDisabled();%0A%0A%09%09%09// both buttons should be %22clickable%22%0A%09%09%09equal( prev.length, 0 );%0A%09%09%09equal( next.length, 0 );%0A%09%09%09start();%0A%09%09%7D, 500);%0A%09%7D);
 %0A%7D;%0A

test that nav is enabled when scrolled from the ends