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 --- .../test_nsIAbDirectory_getMailListFromName.js | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 comm/mailnews/addrbook/test/unit/test_nsIAbDirectory_getMailListFromName.js (limited to 'comm/mailnews/addrbook/test/unit/test_nsIAbDirectory_getMailListFromName.js') diff --git a/comm/mailnews/addrbook/test/unit/test_nsIAbDirectory_getMailListFromName.js b/comm/mailnews/addrbook/test/unit/test_nsIAbDirectory_getMailListFromName.js new file mode 100644 index 0000000000..7d51cecee1 --- /dev/null +++ b/comm/mailnews/addrbook/test/unit/test_nsIAbDirectory_getMailListFromName.js @@ -0,0 +1,40 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * Test suite for the getMailListFromName() function. + */ + +"use strict"; + +/** + * Tests the getMailListFromName function returns the correct nsIAbDirectory, + * also tests the hasMailListWithName function as it uses the same code. + */ +add_task(function testGetMailListFromName() { + loadABFile("../../../data/abLists1", kPABData.fileName); + + // Test all top level lists are returned. + let root = MailServices.ab.getDirectory(kPABData.URI); + for (let listName of ["TestList1", "TestList2", "TestList3"]) { + Assert.ok(root.hasMailListWithName(listName), `parent has "${listName}"`); + + let list = root.getMailListFromName(listName); + Assert.ok(list, `"${listName}" is not null`); + Assert.equal( + list.dirName, + listName, + `"${listName}" dirName is "${listName}"` + ); + } + + Assert.ok( + !root.hasMailListWithName("Non existent"), + "hasMailListWithName() returns false for non-existent list name" + ); + Assert.ok( + !root.getMailListFromName("Non existent"), + "getMailListFromName() returns null for non-existent list name" + ); +}); -- cgit v1.2.3