Daniel Werner has submitted this change and it was merged.
Change subject: Basic toggler widget tests
......................................................................
Basic toggler widget tests
Change-Id: I2e1281057fc537a9fe17c85c8eb9f631c473023b
---
M ValueView/ValueView.tests.qunit.php
M ValueView/resources/jquery.ui/jquery.ui.toggler.js
A ValueView/tests/qunit/jquery.ui/jquery.ui.toggler.tests.js
3 files changed, 84 insertions(+), 5 deletions(-)
Approvals:
Daniel Werner: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/ValueView/ValueView.tests.qunit.php
b/ValueView/ValueView.tests.qunit.php
index f1c38f1..4df648e 100644
--- a/ValueView/ValueView.tests.qunit.php
+++ b/ValueView/ValueView.tests.qunit.php
@@ -99,6 +99,15 @@
),
),
+ 'jquery.ui.toggler.tests' => array(
+ 'scripts' => array(
+ "$bp/jquery.ui/jquery.ui.toggler.tests.js",
+ ),
+ 'dependencies' => array(
+ 'jquery.ui.toggler',
+ ),
+ ),
+
'jquery.valueview.MockViewState.tests' => array(
'scripts' => array(
"$bp/jquery.valueview/valueview.MockViewState.tests.js",
diff --git a/ValueView/resources/jquery.ui/jquery.ui.toggler.js
b/ValueView/resources/jquery.ui/jquery.ui.toggler.js
index 2dacdd4..88b5180 100644
--- a/ValueView/resources/jquery.ui/jquery.ui.toggler.js
+++ b/ValueView/resources/jquery.ui/jquery.ui.toggler.js
@@ -18,7 +18,7 @@
* (2) {number} now
* (3) {jQuery.Tween} tween
*
- * @dependency jquery.ui.Widget
+ * @dependency jQuery.Widget
*/
( function( $ ) {
'use strict';
@@ -51,7 +51,7 @@
}
// Check for support of transformation (see
https://gist.github.com/1031421)
- var img = (new Image).style;
+ var img = (new Image()).style;
browserSupportsTransform = 'transition' in img // general
|| 'msTransform' in img
|| 'webkitTransition' in img; // Webkit
@@ -81,7 +81,7 @@
$toggleIcon: null,
/**
- * @see jQuery.ui.Widget._create
+ * @see jQuery.Widget._create
*/
_create: function() {
var self = this;
@@ -131,12 +131,12 @@
},
/**
- * @see jQuery.ui.Widget
+ * @see jQuery.Widget.destroy
*/
destroy: function() {
var label = this.element.children( this.widgetBaseClass
+ '-label' ).text();
this.element.empty().text( label );
- $.ui.Widget.prototype.destroy.call( this );
+ $.Widget.prototype.destroy.call( this );
},
/**
diff --git a/ValueView/tests/qunit/jquery.ui/jquery.ui.toggler.tests.js
b/ValueView/tests/qunit/jquery.ui/jquery.ui.toggler.tests.js
new file mode 100644
index 0000000..141d308
--- /dev/null
+++ b/ValueView/tests/qunit/jquery.ui/jquery.ui.toggler.tests.js
@@ -0,0 +1,70 @@
+/**
+ * @since 0.1
+ * @ingroup ValueView
+ *
+ * @licence GNU GPL v2+
+ * @author H. Snater < [email protected] >
+ */
+
+( function( $, QUnit ) {
+ 'use strict';
+
+ /**
+ * Factory for creating an toggler widget suitable for testing.
+ *
+ * @param {Object} options
+ * @return {jQuery.ui.toggler}
+ */
+ var newTestToggler = function( options ) {
+ var $defaultDiv = $( '<div/>' )
+ .addClass( 'test_toggler-subject' )
+ .css( 'display', 'none' )
+ .text( 'test' )
+ .appendTo( 'body' );
+
+ options = $.extend( { $subject: $defaultDiv }, options );
+
+ var $div = $( '<div/>' )
+ .addClass( 'test_toggler' )
+ .appendTo( $( 'body' ) )
+ .toggler( options );
+
+ return $div.data( 'toggler' );
+ };
+
+ QUnit.module( 'jquery.ui.toggler', QUnit.newMwEnvironment( {
+ teardown: function() {
+ $( '.test_toggler' ).each( function( i, node ) {
+ if( $( node ).data( 'toggler' ) ) {
+ $( node ).data( 'toggler' ).destroy();
+ }
+ $( node ).remove();
+ } );
+ $( '.test_toggler-subject' ).remove();
+ }
+ } ) );
+
+ QUnit.test( 'Initialization and destruction', 3, function( assert ) {
+ var toggler = newTestToggler();
+
+ assert.equal(
+ $( '.test_toggler' ).data( 'toggler' ),
+ toggler,
+ 'Initialized widget.'
+ );
+
+ toggler.destroy();
+
+ assert.ok(
+ $( '.test_toggler' ).data( 'toggler' ) === undefined,
+ 'Destroyed widget.'
+ );
+
+ assert.equal(
+ $( '.test_toggler-subject' ).length,
+ 1,
+ 'Toggler subject still exists.'
+ );
+ } );
+
+}( jQuery, QUnit ) );
--
To view, visit https://gerrit.wikimedia.org/r/65289
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2e1281057fc537a9fe17c85c8eb9f631c473023b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits