Debian Codegraph @

extensions/MultimediaViewer/tests/qunit/mmv/ui/mmv.ui.description.test.js

raw symbols SCIP
1 const { Description } = require( 'mmv' );
2
3 ( function () {
4 QUnit.module( 'mmv.ui.description', QUnit.newMwEnvironment() );
5
6 QUnit.test( 'Sense test, object creation and UI construction', ( assert ) => {
7 const description = new Description( $( '#qunit-fixture' ) );
8
9 assert.true( description instanceof Description, 'Image description UI element is created' );
10 assert.strictEqual( description.$imageDescDiv.length, 1, 'Image description div is created' );
11 assert.strictEqual( description.$imageDesc.length, 1, 'Image description element is created' );
12 } );
13
14 QUnit.test( 'Setting data in different combinations works well', ( assert ) => {
15 const description = new Description( $( '#qunit-fixture' ) );
16
17 description.set( null, null );
18 assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), true,
19 'Image description div is marked empty when neither description nor caption is available' );
20
21 description.set( null, 'foo' );
22 assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), true,
23 'Image description div is marked empty when there is no description' );
24
25 description.set( 'blah', null );
26 assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), true,
27 'Image description div is marked empty when there is no caption (description will be shown in title)' );
28
29 description.set( 'foo', 'bar' );
30 assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), false,
31 'Image description div is not marked empty when both description and caption are available' );
32 assert.strictEqual( description.$imageDesc.text(), 'foo',
33 'Image description text is set correctly, caption is ignored' );
34 } );
35
36 QUnit.test( 'Emptying data works as expected', ( assert ) => {
37 const description = new Description( $( '#qunit-fixture' ) );
38
39 description.set( 'foo', 'bar' );
40 description.empty();
41 assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), true, 'Image description div is marked empty when emptied' );
42 assert.strictEqual( description.$imageDesc.text(), '', 'Image description text is emptied correctly' );
43 } );
44 }() );