From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../test/unit/test_toOneLineAddress.js | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 browser/extensions/formautofill/test/unit/test_toOneLineAddress.js (limited to 'browser/extensions/formautofill/test/unit/test_toOneLineAddress.js') diff --git a/browser/extensions/formautofill/test/unit/test_toOneLineAddress.js b/browser/extensions/formautofill/test/unit/test_toOneLineAddress.js new file mode 100644 index 0000000000..478a22578e --- /dev/null +++ b/browser/extensions/formautofill/test/unit/test_toOneLineAddress.js @@ -0,0 +1,64 @@ +"use strict"; + +var FormAutofillUtils; +add_setup(async () => { + ({ FormAutofillUtils } = ChromeUtils.import( + "resource://autofill/FormAutofillUtils.jsm" + )); +}); + +add_task(async function test_getCategoriesFromFieldNames() { + const TEST_CASES = [ + { + strings: ["A", "B", "C", "D"], + expectedValue: "A B C D", + }, + { + strings: ["A", "B", "", "D"], + expectedValue: "A B D", + }, + { + strings: ["", "B", "", "D"], + expectedValue: "B D", + }, + { + strings: [null, "B", " ", "D"], + expectedValue: "B D", + }, + { + strings: "A B C", + expectedValue: "A B C", + }, + { + strings: "A\nB\n\n\nC", + expectedValue: "A B C", + }, + { + strings: "A B \nC", + expectedValue: "A B C", + }, + { + strings: "A-B-C", + expectedValue: "A B C", + delimiter: "-", + }, + { + strings: "A B\n \nC", + expectedValue: "A B C", + }, + { + strings: null, + expectedValue: "", + }, + ]; + + for (let tc of TEST_CASES) { + let result; + if (tc.delimiter) { + result = FormAutofillUtils.toOneLineAddress(tc.strings, tc.delimiter); + } else { + result = FormAutofillUtils.toOneLineAddress(tc.strings); + } + Assert.equal(result, tc.expectedValue); + } +}); -- cgit v1.2.3