From 655657fbc57465eeb55b02468fb1acf81db52988 Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Tue, 17 Sep 2024 20:23:07 -0400 Subject: [PATCH] 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 --- tests/js/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/js/index.js b/tests/js/index.js index d391133..747968d 100644 --- a/tests/js/index.js +++ b/tests/js/index.js @@ -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' ); } );