diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/extensions/formautofill/test/unit/test_addressComponent_organization.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/extensions/formautofill/test/unit/test_addressComponent_organization.js')
-rw-r--r-- | browser/extensions/formautofill/test/unit/test_addressComponent_organization.js | 54 |
1 files changed, 54 insertions, 0 deletions
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..3954e9bac7 --- /dev/null +++ b/browser/extensions/formautofill/test/unit/test_addressComponent_organization.js @@ -0,0 +1,54 @@ +"use strict"; + +// prettier-ignore +const VALID_TESTS = [ + ["Mozilla", true], + ["mozilla", true], + ["@Mozilla", true], + ["-!@#%&*_(){}[:;\"',.?]", 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 }; + }); +}); |