2014-02-17 15:09:23 +00:00
|
|
|
( function ( mw, $ ) {
|
|
|
|
QUnit.module( 'mmv.ui', QUnit.newMwEnvironment() );
|
|
|
|
|
2014-03-26 23:59:04 +00:00
|
|
|
QUnit.test( 'handleEvent()', 1, function ( assert ) {
|
|
|
|
var element = new mw.mmv.ui.Element( $( '<div>' ) );
|
2014-02-17 15:09:23 +00:00
|
|
|
|
2014-03-26 23:59:04 +00:00
|
|
|
element.handleEvent( 'mmv-foo', function () {
|
|
|
|
assert.ok( true, 'Event is handled' );
|
|
|
|
} );
|
2014-02-17 15:09:23 +00:00
|
|
|
|
2014-03-26 23:59:04 +00:00
|
|
|
$( document ).trigger( new $.Event( 'mmv-foo' ) );
|
|
|
|
|
|
|
|
element.clearEvents();
|
|
|
|
|
|
|
|
$( document ).trigger( new $.Event( 'mmv-foo' ) );
|
2014-02-17 15:09:23 +00:00
|
|
|
} );
|
2014-04-02 00:07:51 +00:00
|
|
|
|
2014-04-04 22:02:16 +00:00
|
|
|
QUnit.test( 'setInlineStyle()', 3, function ( assert ) {
|
2014-04-02 00:07:51 +00:00
|
|
|
var element = new mw.mmv.ui.Element( $( '<div>' ) ),
|
|
|
|
$testDiv = $( '<div id="mmv-testdiv">!!!</div>' ).appendTo( '#qunit-fixture' );
|
|
|
|
|
|
|
|
assert.ok( $testDiv.is( ':visible' ), 'Test div is visible' );
|
|
|
|
|
2014-04-04 22:02:16 +00:00
|
|
|
element.setInlineStyle( 'test', '#mmv-testdiv { display: none; }' );
|
2014-04-02 00:07:51 +00:00
|
|
|
|
|
|
|
assert.ok( !$testDiv.is( ':visible' ), 'Test div is hidden by inline style' );
|
|
|
|
|
2014-04-04 22:02:16 +00:00
|
|
|
element.setInlineStyle( 'test', null );
|
2014-04-02 00:07:51 +00:00
|
|
|
|
|
|
|
assert.ok( $testDiv.is( ':visible' ), 'Test div is visible again' );
|
|
|
|
} );
|
2014-02-17 15:09:23 +00:00
|
|
|
}( mediaWiki, jQuery ) );
|