forked from mirrors/gecko-dev
--HG-- rename : browser/extensions/formautofill/bootstrap.js => browser/extensions/formautofill/api.js rename : browser/extensions/formautofill/install.rdf.in => browser/extensions/formautofill/manifest.json rename : browser/extensions/formautofill/skin/shared/autocomplete-item.css => browser/extensions/formautofill/skin/shared/autocomplete-item-shared.css rename : browser/extensions/formautofill/skin/shared/editDialog.css => browser/extensions/formautofill/skin/shared/editDialog-shared.css extra : rebase_source : 233ea805630209a07d347e19f19710d9755f595f extra : source : ecda6532c852b3f225fce998e3ce83ad157760e6
62 lines
1.2 KiB
JavaScript
62 lines
1.2 KiB
JavaScript
|
|
"use strict";
|
|
|
|
add_task(async function setup() {
|
|
ChromeUtils.import("resource://formautofill/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);
|
|
}
|
|
});
|