Skip to content

Commit

Permalink
Updates for the unique autonyms test (#383)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
amire80 and srish authored Sep 18, 2024
1 parent d8af862 commit 655657f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe( 'languagedata', function () {
duplicateAutonyms.push( language );
}

autonyms.push( autonym );
autonyms.push( autonym.toLowerCase() );
}

return duplicateAutonyms;
Expand Down Expand Up @@ -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.' );
Expand Down Expand Up @@ -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' );
} );
Expand Down

0 comments on commit 655657f

Please sign in to comment.