Updates for the unique autonyms test (#383)

* Move the unique autonyms test to the "autonyms" section

It was in the "redirects" section, and it makes
much more sense for it to be in the "autonyms" section.

* Case-insensitive test for unique autonyms

Autonyms for some languages are very similar or even identical,
but they should be unique in this system so that users
would be able to find the correct language unambiguously.

It's conceivable that someone (including myself) would add
an autonym that will be different only in its usage of
capital letters. This change modifies the test for
unique autonyms so that such cases would be prevented.

---------

Co-authored-by: SrishAkaTux <ssethi@wikimedia.org>
This commit is contained in:
Amir E. Aharoni
2024-09-17 20:23:07 -04:00
committed by GitHub
parent d8af8623ad
commit 655657fbc5

View File

@@ -83,7 +83,7 @@ describe( 'languagedata', function () {
duplicateAutonyms.push( language );
}
autonyms.push( autonym );
autonyms.push( autonym.toLowerCase() );
}
return duplicateAutonyms;
@@ -122,6 +122,7 @@ describe( 'languagedata', function () {
assert.ok( languageData.getAutonym( 'qqq' ), 'Language documentation', 'Language qqq was added with the correct autonym' );
autonyms = languageData.getAutonyms();
assert.strictEqual( autonyms[ 'zu' ], 'isiZulu', 'Correct autonym is returned for Zulu using getAutonyms().' );
assert.deepEqual( doubleAutonyms(), [], 'All languages have distinct autonyms.' );
assert.strictEqual( autonyms[ 'pa' ], undefined, 'Language "pa" is not listed in autonyms, because it is a redirect' );
assert.strictEqual( autonyms[ 'pa-guru' ], 'ਪੰਜਾਬੀ', 'Language "pa-guru" has the correct autonym' );
assert.deepEqual( languagesWithoutAutonym(), [], 'All languages have autonyms.' );
@@ -180,7 +181,6 @@ 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' );
} );