2014-03-17 08:07:53 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the MediaWiki extension MultimediaViewer.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2023-05-20 08:30:52 +00:00
|
|
|
const { Share } = require( 'mmv.ui.reuse.shareembed' );
|
|
|
|
|
2018-11-12 16:33:24 +00:00
|
|
|
( function () {
|
2014-03-17 08:07:53 +00:00
|
|
|
function makeShare() {
|
2023-05-20 08:30:52 +00:00
|
|
|
return new Share( $( '#qunit-fixture' ) );
|
2014-03-17 08:07:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QUnit.module( 'mmv.ui.reuse.share', QUnit.newMwEnvironment() );
|
|
|
|
|
2021-12-10 00:43:28 +00:00
|
|
|
QUnit.test( 'Sense test, object creation and UI construction', function ( assert ) {
|
2023-10-24 09:53:23 +00:00
|
|
|
const share = makeShare();
|
2014-03-17 08:07:53 +00:00
|
|
|
|
2023-05-20 08:30:52 +00:00
|
|
|
assert.true( share instanceof Share, 'Share UI element is created.' );
|
2024-05-04 14:00:17 +00:00
|
|
|
assert.true( share.$pageInput[ 0 ] instanceof HTMLElement, 'Text field created.' );
|
2014-03-17 08:07:53 +00:00
|
|
|
} );
|
|
|
|
|
2017-07-25 23:38:21 +00:00
|
|
|
QUnit.test( 'set()/empty():', function ( assert ) {
|
2023-10-24 09:53:23 +00:00
|
|
|
const share = makeShare();
|
|
|
|
const image = { // fake ImageModel
|
|
|
|
title: new mw.Title( 'File:Foobar.jpg' ),
|
|
|
|
url: 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg',
|
|
|
|
descriptionUrl: '//commons.wikimedia.org/wiki/File:Foobar.jpg'
|
|
|
|
};
|
2014-03-17 08:07:53 +00:00
|
|
|
|
2024-05-04 14:00:17 +00:00
|
|
|
assert.notStrictEqual( !share.$pageInput.val(), '', 'pageInput is empty.' );
|
2014-03-17 08:07:53 +00:00
|
|
|
|
2014-03-19 22:35:55 +00:00
|
|
|
share.select = function () {
|
2022-05-20 00:18:43 +00:00
|
|
|
assert.true( true, 'Text has been selected after data is set.' );
|
2014-03-19 22:35:55 +00:00
|
|
|
};
|
|
|
|
|
2014-03-17 08:07:53 +00:00
|
|
|
share.set( image );
|
|
|
|
|
2024-05-04 14:00:17 +00:00
|
|
|
assert.notStrictEqual( share.$pageInput.val(), '', 'pageInput is not empty.' );
|
2014-03-17 08:07:53 +00:00
|
|
|
|
|
|
|
share.empty();
|
|
|
|
|
2024-05-04 14:00:17 +00:00
|
|
|
assert.notStrictEqual( !share.$pageInput.val(), '', 'pageInput is empty.' );
|
2014-03-17 08:07:53 +00:00
|
|
|
} );
|
|
|
|
|
2018-11-12 16:33:24 +00:00
|
|
|
}() );
|