From 81f84a80a5a069d787360976952457a1b7a938f8 Mon Sep 17 00:00:00 2001 From: aabboudi Date: Wed, 16 Oct 2024 23:49:47 +0100 Subject: [PATCH] Added test cases for allow_idn option --- test/validators.test.js | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/test/validators.test.js b/test/validators.test.js index 31a36d029..ebd32c44d 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -140,6 +140,29 @@ describe('Validators', () => { }); }); + it('should not validate email addresses with non-ASCII domain names if allow_idn is set to false', () => { + test({ + validator: 'isEmail', + args: [{ allow_idn: false }], + valid: [], + invalid: [ + "ka25maj@gˇmail.com", // Original issue example + "i18n@exampلe.com", // Arabic + "i18n@EXАМПЛЕ.com", // Cyrillic + "i18n@exамple.com", // Cyrillic + 'i18n@éxample.com', // French + 'i18n@eßample.com', // German + "i18n@EXΑΜΠΛΕ.com", // Greek + "i18n@exαmple.com", // Greek + 'i18n@exampłe.com', // Polish + 'i18n@eซample.com', // Thai + "i18n@例題.com", // Chinese + "i18n@例え.com", // Japanese + "i18n@사례.com", // Korean + ], + }); + }); + it('should validate email addresses with display names', () => { test({ validator: 'isEmail', @@ -828,6 +851,29 @@ describe('Validators', () => { }); }); + it('should not validate URLs with non-ASCII domain names if allow_idn is set to false', () => { + test({ + validator: 'isURL', + args: [{ allow_idn: false }], + valid: [], + invalid: [ + "gˇmail.com", // Original issue example + "exampلe.com", // Arabic + "EXАМПЛЕ.com", // Cyrillic + "exамple.com", // Cyrillic + 'éxample.com', // French + 'eßample.com', // German + "EXΑΜΠΛΕ.com", // Greek + "exαmple.com", // Greek + 'exampłe.com', // Polish + 'eซample.com', // Thai + "例題.com", // Chinese + "例え.com", // Japanese + "사례.com", // Korean + ], + }); + }); + it('should validate MAC addresses', () => { test({ validator: 'isMACAddress',