diff options
Diffstat (limited to 'www/wiki/extensions/UploadWizard/tests/qunit/mw.UploadWizardLicenseInput.test.js')
-rw-r--r-- | www/wiki/extensions/UploadWizard/tests/qunit/mw.UploadWizardLicenseInput.test.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/www/wiki/extensions/UploadWizard/tests/qunit/mw.UploadWizardLicenseInput.test.js b/www/wiki/extensions/UploadWizard/tests/qunit/mw.UploadWizardLicenseInput.test.js new file mode 100644 index 00000000..ff7e83d5 --- /dev/null +++ b/www/wiki/extensions/UploadWizard/tests/qunit/mw.UploadWizardLicenseInput.test.js @@ -0,0 +1,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 ) ); |