mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add test cases
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<!doctype html>
|
||||
<!-- Minimal outline test page for a requirejs+qunit testing setup,
|
||||
test environment is bootstrapped in test-common.js -->
|
||||
<html>
|
||||
<head>
|
||||
<link href="../../../static/style/blue/base.css" media="screen" rel="stylesheet" type="text/css">
|
||||
<script data-main="../test-common" src="../scripts/libs/require.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,71 @@
|
||||
/* global define, QUnit, module, test, ok, equal, deepEqual, notEqual */
|
||||
define([ 'test-app', 'mvc/ui/ui-misc'
|
||||
], function( testApp, Ui ){
|
||||
'use strict';
|
||||
module( 'Ui test', {} );
|
||||
|
||||
test( 'label', function() {
|
||||
var label = new Ui.Label({
|
||||
title : '_title'
|
||||
});
|
||||
$( 'body' ).prepend( label.$el );
|
||||
ok( label.$el.html() === '_title', 'Correct title' );
|
||||
label.model.set( 'title', '_new_title' );
|
||||
ok( label.$el.html() === '_new_title', 'Correct new title' );
|
||||
} );
|
||||
|
||||
test( 'input', function() {
|
||||
var input = new Ui.Input();
|
||||
$( 'body' ).prepend( input.$el );
|
||||
ok( input.tagName === 'input', 'Created input.' );
|
||||
ok( input.value() === undefined, 'Input empty.' );
|
||||
input.model.set( 'value', '_value' );
|
||||
ok( input.$el.val() === '_value', 'Input empty.' );
|
||||
ok( !input.$el.hasClass( '_cls' ), 'Has no custom class.' );
|
||||
input.model.set( 'cls', '_cls' );
|
||||
ok( input.$el.hasClass( '_cls' ), 'Has custom class.' );
|
||||
ok( !input.$el.attr( 'placeholder' ), 'Has no placeholder' );
|
||||
input.model.set( 'placeholder', '_placeholder' );
|
||||
ok( input.$el.attr( 'placeholder' ) === '_placeholder', 'Has correct placeholder' );
|
||||
} );
|
||||
|
||||
test( 'textarea', function() {
|
||||
var input = new Ui.Input( { area: true } );
|
||||
$( 'body' ).prepend( input.$el );
|
||||
ok( input.tagName === 'textarea', 'Created textarea.' );
|
||||
ok( input.value() === undefined, 'Input empty.' );
|
||||
input.model.set( 'value', '_value' );
|
||||
ok( input.value() === '_value', 'Input empty.' );
|
||||
ok( !input.$el.hasClass( '_cls' ), 'Has no custom class.' );
|
||||
input.model.set( 'cls', '_cls' );
|
||||
ok( input.$el.hasClass( '_cls' ), 'Has custom class.' );
|
||||
} );
|
||||
|
||||
test( 'message', function() {
|
||||
var message = new Ui.Message({
|
||||
persistent : true,
|
||||
message : '_message',
|
||||
status : 'danger'
|
||||
});
|
||||
$( 'body' ).prepend( message.$el );
|
||||
ok( message.$el.hasClass( 'alert-danger' ), 'Alert danger.' );
|
||||
message.model.set( 'status', 'info' );
|
||||
ok( !message.$el.hasClass( 'alert-danger' ), 'Alert danger (disabled).' );
|
||||
ok( message.$el.hasClass( 'alert-info' ), 'Alert info.' );
|
||||
ok( message.$el.html() === '_message', 'Correct message.' );
|
||||
message.model.set( 'message', '_new_message' );
|
||||
ok( message.$el.html() === '_new_message', 'Correct message.' );
|
||||
} );
|
||||
|
||||
test( 'hidden', function() {
|
||||
var hidden = new Ui.Hidden();
|
||||
$( 'body' ).prepend( hidden.$el );
|
||||
hidden.model.set( 'info', '_info' );
|
||||
ok( hidden.$info.css( 'display', 'block' ), 'Info shown.' );
|
||||
ok( hidden.$info.html() === '_info', 'Info text correct.' );
|
||||
hidden.model.set( 'info', '' );
|
||||
ok( hidden.$info.css( 'display', 'none' ), 'Info hidden.' );
|
||||
hidden.model.set( 'value', '_value' );
|
||||
ok( hidden.$hidden.val() === '_value', 'Correct value' );
|
||||
} );
|
||||
});
|
||||
Reference in New Issue
Block a user