Test for double redirects

This commit is contained in:
Amir E. Aharoni
2012-12-30 19:27:36 +02:00
parent 683ad727e1
commit 2ce57b37fe

View File

@@ -51,6 +51,24 @@
return result;
};
/*
* Runs over all languages and checks that all redirects point to a language.
* There's no reason to have double redirects.
*/
var doubleRedirects = function () {
var result = [];
for ( var language in $.uls.data.languages ) {
var target = $.uls.data.isRedirect( language );
if ( target && $.uls.data.isRedirect( target ) ) {
result.push( language );
}
}
return result;
};
/*
* Runs over all script codes mentioned in langdb and checks whether
* they have something that looks like an autonym.
@@ -71,7 +89,7 @@
assert.ok( $.fn.uls, "$.fn.uls is defined" );
} );
test( "-- $.uls.data testing", 40, function ( assert ) {
test( "-- $.uls.data testing", 41, function ( assert ) {
assert.strictEqual( $.uls.data.isRedirect( 'sr-ec' ), 'sr-cyrl', "'sr-ec' is a redirect to 'sr-cyrl'" );
var autonyms = $.uls.data.getAutonyms();
@@ -82,7 +100,9 @@
// This test assumes that we don't want any scripts to be in the 'Other'
// group. Actually, this may become wrong some day.
assert.deepEqual( orphanScripts(), [], 'All scripts belong to script groups.' );
assert.deepEqual( badRedirects(), [], 'All redirects have valid targets.' );
assert.deepEqual( doubleRedirects(), [], 'There are no double redirects.' );
assert.deepEqual( languagesWithoutAutonym(), [], 'All languages have autonyms.' );
assert.strictEqual(