Merge "Make License.isCc() really return booleans"

This commit is contained in:
jenkins-bot 2014-04-23 22:59:25 +00:00 committed by Gerrit Code Review
commit fe7a64fbcc
2 changed files with 16 additions and 1 deletions

View file

@ -60,7 +60,7 @@
* @returns {boolean}
*/
LP.isCc = function () {
return this.internalName && this.internalName.substr( 0, 2 ) === 'cc';
return this.internalName ? this.internalName.substr( 0, 2 ) === 'cc' : false;
};
/**

View file

@ -101,4 +101,19 @@
'Title for license with link is formatted correctly' );
} );
QUnit.test( 'isCc()', 3, function( assert ) {
var license;
license = new mw.mmv.model.License( 'CC-BY-SA-2.0', 'cc-by-sa-2.0',
'Creative Commons Attribution - ShareAlike 2.0',
'http://creativecommons.org/licenses/by-sa/2.0/' );
assert.strictEqual( license.isCc(), true, 'CC license recognized' );
license = new mw.mmv.model.License( 'Public Domain', 'pd',
'Public Domain for lack of originality' );
assert.strictEqual( license.isCc(), false, 'Non-CC license not recognized' );
license = new mw.mmv.model.License( 'MIT' );
assert.strictEqual( license.isCc(), false, 'Non-CC license with no internal name not recognized' );
} );
}( mediaWiki, jQuery ) );