mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-25 00:25:47 +00:00
22d2a69979
* Move description and caption to both be in the bottom left * Make empty description grey and italic * Fix problem where description was sometimes appended twice * Move description UI stuff into a separate file, and make it more MVCy * Tests for description UI stuff * General framework, to an extent, for UI classes Change-Id: Ibc8c576cd8a41c2e3cf7e13f1b9e093384fb4655 Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/120
41 lines
2.4 KiB
JavaScript
41 lines
2.4 KiB
JavaScript
( function ( mw, $ ) {
|
|
QUnit.module( 'ext.multimediaViewer.ui.description', QUnit.newMwEnvironment() );
|
|
|
|
QUnit.test( 'Sanity test, object creation and UI construction', 4, function ( assert ) {
|
|
var description = new mw.mmv.ui.Description( $( '#qunit-fixture' ) );
|
|
|
|
assert.ok( description, 'Image description UI element is created' );
|
|
assert.strictEqual( description.$imageDescDiv.length, 1, 'Image description div is created' );
|
|
assert.strictEqual( description.$imageDesc.length, 1, 'Image description element is created' );
|
|
assert.strictEqual( description.$imageCaption.length, 1, 'Image caption div is created' );
|
|
} );
|
|
|
|
QUnit.test( 'Setting data in different combinations works well', 7, function ( assert ) {
|
|
var description = new mw.mmv.ui.Description( $( '#qunit-fixture' ) );
|
|
|
|
description.set( '' );
|
|
assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), true, 'Image description div is marked empty when needed' );
|
|
|
|
description.set( 'blah' );
|
|
assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), false, 'Image description div is not marked empty incorrectly' );
|
|
assert.strictEqual( description.$imageDesc.text(), 'blah', 'Image description text is set correctly' );
|
|
assert.strictEqual( description.$imageCaption.hasClass( 'empty' ), true, 'Image caption is empty when not set' );
|
|
|
|
description.set( 'foo', 'bar' );
|
|
assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), false, 'Image description div is not marked empty incorrectly' );
|
|
assert.strictEqual( description.$imageCaption.text(), 'bar', 'Image caption text is set correctly' );
|
|
assert.strictEqual( description.$imageCaption.hasClass( 'empty' ), false, 'Image caption is not marked empty when set' );
|
|
} );
|
|
|
|
QUnit.test( 'Emptying data works as expected', 4, function ( assert ) {
|
|
var description = new mw.mmv.ui.Description( $( '#qunit-fixture' ) );
|
|
|
|
description.set( 'foo', 'bar' );
|
|
description.empty();
|
|
assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), true, 'Image description div is marked empty when emptied' );
|
|
assert.strictEqual( description.$imageCaption.hasClass( 'empty' ), true, 'Image caption is marked empty when emptied' );
|
|
assert.strictEqual( description.$imageDesc.text(), '', 'Image description text is emptied correctly' );
|
|
assert.strictEqual( description.$imageCaption.text(), '', 'Image caption text is emptied correctly' );
|
|
} );
|
|
}( mediaWiki, jQuery ) );
|