| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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 = { |
| 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 |
}() ); |