Sync language data base with jquery.uls language data

This avoids the mismatch with jquery.uls database in preparation to
replace jquery.uls data with language-data module
This commit is contained in:
Santhosh Thottingal
2017-08-28 17:40:12 +05:30
parent 246f9925bd
commit bede5f48fe
3 changed files with 277 additions and 63 deletions

View File

@@ -2,7 +2,7 @@ var languageData = require( '../index' ),
assert = require( 'assert' );
describe( 'languagedata', function () {
var orphanScripts, badRedirects, doubleRedirects, languagesWithoutAutonym;
var orphanScripts, badRedirects, doubleRedirects, doubleAutonyms, languagesWithoutAutonym;
/*
* Runs over all script codes mentioned in langdb and checks whether
* they belong to the 'Other' group.
@@ -47,6 +47,30 @@ describe( 'languagedata', function () {
}
return result;
};
/*
* Runs over all languages and checks that all autonyms are unique.
*/
doubleAutonyms = function () {
var language, autonym,
autonyms = [],
duplicateAutonyms = [];
for ( language in languageData.languages ) {
if ( languageData.isRedirect( language ) ) {
continue;
}
autonym = languageData.getAutonym( language );
if ( autonyms.indexOf( autonym ) > -1 ) {
duplicateAutonyms.push( language );
}
autonyms.push( autonym );
}
return duplicateAutonyms;
};
/*
* Runs over all script codes mentioned in langdb and checks whether
* they have something that looks like an autonym.
@@ -125,6 +149,7 @@ describe( 'languagedata', function () {
assert.strictEqual( languageData.isRedirect( 'sr-ec' ), 'sr-cyrl', '"sr-ec" is a redirect to "sr-cyrl"' );
assert.deepEqual( badRedirects(), [], 'All redirects have valid targets.' );
assert.deepEqual( doubleRedirects(), [], 'There are no double redirects.' );
assert.deepEqual( doubleAutonyms(), [], 'All languages have distinct autonyms.' );
assert.strictEqual( languageData.getScript( 'no-such-language' ), 'Zyyy', 'A script for an unknown language is Zyyy - undetermined' );
assert.strictEqual( languageData.getScript( 'ii' ), 'Yiii', 'Correct script of the Yi language was selected' );
} );