mediawiki-extensions-Multim.../tests/qunit/mmv/ui/mmv.ui.reuse.share.test.js
Ed Sanders 394b893c7d Use upstream CopyTextLayout in share/embed/download panels
Results in small UI changes, but allows us to delete a lot
of code duplication.

Depends-On: I9049f5a1c0d88680fc4a174e390dd08e27c0eee2
Change-Id: Iebe7bdc8a026b929a35e823d8107d90e7bb62b82
2019-05-23 20:01:36 +01:00

58 lines
2 KiB
JavaScript

/*
* 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/>.
*/
( function () {
function makeShare() {
return new mw.mmv.ui.reuse.Share( $( '#qunit-fixture' ) );
}
QUnit.module( 'mmv.ui.reuse.share', QUnit.newMwEnvironment() );
QUnit.test( 'Sanity test, object creation and UI construction', function ( assert ) {
var share = makeShare();
assert.ok( share, 'Share UI element is created.' );
assert.strictEqual( share.$pane.length, 1, 'Pane div created.' );
assert.ok( share.pageInput, 'Text field created.' );
assert.ok( share.$pageLink, 'Link created.' );
} );
QUnit.test( 'set()/empty():', function ( assert ) {
var share = makeShare(),
image = { // fake mw.mmv.model.Image
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'
};
assert.notStrictEqual( !share.pageInput.textInput.getValue(), '', 'pageInput is empty.' );
share.select = function () {
assert.ok( true, 'Text has been selected after data is set.' );
};
share.set( image );
assert.notStrictEqual( share.pageInput.textInput.getValue(), '', 'pageInput is not empty.' );
share.empty();
assert.notStrictEqual( !share.pageInput.textInput.getValue(), '', 'pageInput is empty.' );
} );
}() );