1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
( function ( mw, $ ) {
QUnit.module( 'ext.uploadWizardLicenseInput', QUnit.newMwEnvironment( {
setup: function () {
mw.UploadWizard.config = {
licenses: {
'cc-by-sa-3.0': {
msg: 'mwe-upwiz-license-cc-by-sa-3.0',
icons: [ 'cc-by', 'cc-sa' ],
url: '//creativecommons.org/licenses/by-sa/3.0/',
languageCodePrefix: 'deed.'
}
}
};
}
} ) );
QUnit.test( 'Smoke test', function ( assert ) {
var values,
config = { type: 'or', licenses: [] },
uwLicenseInput;
uwLicenseInput = new mw.UploadWizardLicenseInput( values, config );
$( '#qunit-fixture' ).append( uwLicenseInput.$element );
assert.ok( uwLicenseInput, 'LicenseInput object created !' );
} );
QUnit.test( 'createInputs()', function ( assert ) {
var values,
config = { type: 'or', licenses: [ 'cc-by-sa-3.0' ] },
uwLicenseInput;
uwLicenseInput = new mw.UploadWizardLicenseInput( values, config );
$( '#qunit-fixture' ).append( uwLicenseInput.$element );
// Check radio button is there
assert.strictEqual( $( '.mwe-upwiz-copyright-info-radio' ).length, 1, 'Radio button created.' );
// Check label is there
assert.strictEqual( $( '.mwe-upwiz-copyright-info' ).length, 1, 'Label created.' );
} );
QUnit.test( 'createGroupedInputs()', function ( assert ) {
var values,
config = {
type: 'or',
licenseGroups: [
{
head: 'mwe-upwiz-license-cc-head',
subhead: 'mwe-upwiz-license-cc-subhead',
licenses: [ 'cc-by-sa-3.0' ]
}
]
},
uwLicenseInput;
uwLicenseInput = new mw.UploadWizardLicenseInput( values, config );
$( '#qunit-fixture' ).append( uwLicenseInput.$element );
// Check license group is there
assert.strictEqual( $( '.mwe-upwiz-deed-license-group' ).length, 1, 'License group created.' );
// Check subheader is there
assert.strictEqual( $( '.mwe-upwiz-deed-license-group-subhead' ).length, 1, 'License subheader created.' );
// Check license is there
assert.strictEqual( $( '.mwe-upwiz-deed-license' ).length, 1, 'License created.' );
} );
}( mediaWiki, jQuery ) );
|