test_addressComponent_organization.js (2120B)
1 "use strict"; 2 3 // prettier-ignore 4 const VALID_TESTS = [ 5 ["Mozilla", true], 6 ["mozilla", true], 7 ["@Mozilla", true], 8 ["-!@#%&*_(){}[:;\"',.?]", false], // Not valid when the organization name only contains punctuations 9 ]; 10 11 const COMPARE_TESTS = [ 12 // Same 13 ["Mozilla", "Mozilla", SAME], // Exact the same 14 15 // Similar 16 ["Mozilla", "mozilla", SIMILAR], // Ignore case 17 ["Casavant Frères", "Casavant Freres", SIMILAR], // asscent and base 18 ["Graphik Dimensions, Ltd.", "Graphik Dimensions Ltd", SIMILAR], // Punctuation is stripped and trim space in the end 19 ["T & T Supermarket", "T&T Supermarket", SIMILAR], // & is stripped and merged consecutive whitespace 20 ["Food & Pharmacy", "Pharmacy & Food", SIMILAR], // Same tokens, different order 21 ["Johnson & Johnson", "Johnson", SIMILAR], // Can always find the same token in the other 22 23 // A Contains B 24 ["Mozilla Inc.", "Mozilla", A_CONTAINS_B], // Contain, the same prefix 25 ["The Walt Disney", "Walt Disney", A_CONTAINS_B], // Contain, the same suffix 26 ["Coca-Cola Company", "Coca Cola", A_CONTAINS_B], // Contain, strip punctuation 27 28 // Different 29 ["Meta", "facebook", DIFFERENT], // Completely different 30 ["Metro Inc.", "CGI Inc.", DIFFERENT], // Different prefix 31 ["AT&T Corp.", "AT&T Inc.", DIFFERENT], // Different suffix 32 ["AT&T Corp.", "AT&T Corporation", DIFFERENT], // Different suffix 33 ["Ben & Jerry's", "Ben & Jerrys", DIFFERENT], // Different because Jerry's becomes ["Jerry", "s"] 34 ["Arc'teryx", "Arcteryx", DIFFERENT], // Different because Arc'teryx' becomes ["Arc", "teryx"] 35 ["BMW", "Bayerische Motoren Werke", DIFFERENT], 36 37 ["Linens 'n Things", "Linens'n Things", SIMILAR], // Punctuation is replaced with whitespace, so both strings become "Linesns n Things" 38 ]; 39 40 const TEST_FIELD_NAME = "organization"; 41 42 add_setup(async () => {}); 43 44 add_task(async function test_isValid() { 45 runIsValidTest(VALID_TESTS, TEST_FIELD_NAME, value => { 46 return { organization: value }; 47 }); 48 }); 49 50 add_task(async function test_compare() { 51 runCompareTest(COMPARE_TESTS, TEST_FIELD_NAME, value => { 52 return { organization: value }; 53 }); 54 });