Debian Codegraph @

extensions/MultimediaViewer/tests/qunit/mmv/ui/mmv.ui.reuse.share.test.js

raw symbols SCIP
1 /*
2 * This file is part of the MediaWiki extension MultimediaViewer.
3 *
4 * MultimediaViewer is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * MultimediaViewer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 const { Share } = require( 'mmv.ui.reuse' );
19
20 ( function () {
21 function makeShare() {
22 return new Share( $( '#qunit-fixture' ) );
23 }
24
25 QUnit.module( 'mmv.ui.reuse.share', QUnit.newMwEnvironment() );
26
27 QUnit.test( 'Sense test, object creation and UI construction', ( assert ) => {
28 const share = makeShare();
29
30 assert.true( share instanceof Share, 'Share UI element is created.' );
31 assert.true( share.$pageInput[ 0 ] instanceof HTMLElement, 'Text field created.' );
32 } );
33
34 QUnit.test( 'set()/empty():', ( assert ) => {
35 const share = makeShare();
36 const image = { // fake ImageModel
37 title: new mw.Title( 'File:Foobar.jpg' ),
38 url: 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg',
39 descriptionUrl: '//commons.wikimedia.org/wiki/File:Foobar.jpg'
40 };
41
42 assert.notStrictEqual( !share.$pageInput.val(), '', 'pageInput is empty.' );
43
44 share.select = function () {
45 assert.true( true, 'Text has been selected after data is set.' );
46 };
47
48 share.set( image );
49
50 assert.notStrictEqual( share.$pageInput.val(), '', 'pageInput is not empty.' );
51
52 share.empty();
53
54 assert.notStrictEqual( !share.$pageInput.val(), '', 'pageInput is empty.' );
55 } );
56
57 }() );