diff options
Diffstat (limited to '')
-rw-r--r-- | comm/mailnews/addrbook/test/unit/test_nsIAbDirectory_getMailListFromName.js | 40 |
1 files changed, 40 insertions, 0 deletions
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" + ); +}); |