From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../unit/test_addressComponent_organization.js | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 browser/extensions/formautofill/test/unit/test_addressComponent_organization.js (limited to 'browser/extensions/formautofill/test/unit/test_addressComponent_organization.js') diff --git a/browser/extensions/formautofill/test/unit/test_addressComponent_organization.js b/browser/extensions/formautofill/test/unit/test_addressComponent_organization.js new file mode 100644 index 0000000000..6790b83599 --- /dev/null +++ b/browser/extensions/formautofill/test/unit/test_addressComponent_organization.js @@ -0,0 +1,55 @@ +"use strict"; + +// prettier-ignore +const VALID_TESTS = [ + ["Mozilla", true], + ["mozilla", true], + ["@Mozilla", true], + [" ", true], // A string only contains whitespace is treated as empty, which is considered as valid + ["-!@#%&*_(){}[:;\"',.?]", false], // Not valid when the organization name only contains punctuations +]; + +const COMPARE_TESTS = [ + // Same + ["Mozilla", "Mozilla", SAME], // Exact the same + + // Similar + ["Mozilla", "mozilla", SIMILAR], // Ignore case + ["Casavant Frères", "Casavant Freres", SIMILAR], // asscent and base + ["Graphik Dimensions, Ltd.", "Graphik Dimensions Ltd", SIMILAR], // Punctuation is stripped and trim space in the end + ["T & T Supermarket", "T&T Supermarket", SIMILAR], // & is stripped and merged consecutive whitespace + ["Food & Pharmacy", "Pharmacy & Food", SIMILAR], // Same tokens, different order + ["Johnson & Johnson", "Johnson", SIMILAR], // Can always find the same token in the other + + // A Contains B + ["Mozilla Inc.", "Mozilla", A_CONTAINS_B], // Contain, the same prefix + ["The Walt Disney", "Walt Disney", A_CONTAINS_B], // Contain, the same suffix + ["Coca-Cola Company", "Coca Cola", A_CONTAINS_B], // Contain, strip punctuation + + // Different + ["Meta", "facebook", DIFFERENT], // Completely different + ["Metro Inc.", "CGI Inc.", DIFFERENT], // Different prefix + ["AT&T Corp.", "AT&T Inc.", DIFFERENT], // Different suffix + ["AT&T Corp.", "AT&T Corporation", DIFFERENT], // Different suffix + ["Ben & Jerry's", "Ben & Jerrys", DIFFERENT], // Different because Jerry's becomes ["Jerry", "s"] + ["Arc'teryx", "Arcteryx", DIFFERENT], // Different because Arc'teryx' becomes ["Arc", "teryx"] + ["BMW", "Bayerische Motoren Werke", DIFFERENT], + + ["Linens 'n Things", "Linens'n Things", SIMILAR], // Punctuation is replaced with whitespace, so both strings become "Linesns n Things" +]; + +const TEST_FIELD_NAME = "Organization"; + +add_setup(async () => {}); + +add_task(async function test_isValid() { + runIsValidTest(VALID_TESTS, TEST_FIELD_NAME, value => { + return { organization: value }; + }); +}); + +add_task(async function test_compare() { + runCompareTest(COMPARE_TESTS, TEST_FIELD_NAME, value => { + return { organization: value }; + }); +}); -- cgit v1.2.3