Skip to content

Commit

Permalink
created unit test files
Browse files Browse the repository at this point in the history
  • Loading branch information
drewlee committed Oct 19, 2012
1 parent 171a3b8 commit ea0ad23
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/components/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Dropdown = Switch.extend( function ( base ) {
href = $button.attr('href');

if( href.indexOf('#') !== 0 ){
window.location = href;
window.location.href = href;
}
}

Expand Down
55 changes: 55 additions & 0 deletions test/dropdown/dropdown.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Dropdown</title>
<link rel="stylesheet" type="text/css" href="../qunit.css">
</head>

<body>

<div id="qunit"></div>

<div id="test-container">
<div id="A" data-lu="Dropdown" class="lu-state-inactive">
<button data-lu="Button:State">Choose...</button>
<ul class="dropdown-list" data-lu="List">
<li><a href="#" data-lu="Button:Select" data-lu-value="A">One</a></li>
<li><a href="#" data-lu="Button:Select" data-lu-value="B">Two</a></li>
<li><a href="#" data-lu="Button:Select" data-lu-value="C">Three</a></li>
<li><a href="#" data-lu="Button:Select" data-lu-value="D">Four</a></li>
<li><a href="#" data-lu="Button:Select" data-lu-value="E">Five</a></li>
</ul>
</div>
</div>

<script src="/scripts/libraries/underscore.js"></script>
<script src="/scripts/libraries/inject/inject.js"></script>
<script src="/scripts/libraries/jquery-1.7.1.min.js"></script>

<script src="/scripts/config.js"></script>
<script src="/scripts/lu.js" ></script>
<script src="/scripts/mappers.js"></script>

<script src="../qunit.js"></script>
<script src="test.js"></script>

<script>

Inject.setExpires( 0 );
Inject.clearCache();
Inject.setModuleRoot( 'http://localhost:1337/' );

window.LU_DEBUG = 5;

Lu.map( $( '[data-lu~=Dropdown]' ), 'Dropdown', function(){} );

Lu.execute( $( 'body' ) ).done( function(){
execute();
} );

</script>

</body>

</html>
12 changes: 12 additions & 0 deletions test/dropdown/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @TODO:
* - test open state
* - test collapsed state
* - test that the appropriate item gets selected from click
* - test that the appropriate items gets selected from enter key
* - test up/down arrow keys
*/

function execute(){
var Dropdown = $( '#A' ).lu( 'getComponent', 'Dropdown' ).instance;
}

0 comments on commit ea0ad23

Please sign in to comment.