diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mailnews/addrbook/test/unit/test_collection_2.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | comm/mailnews/addrbook/test/unit/test_collection_2.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/comm/mailnews/addrbook/test/unit/test_collection_2.js b/comm/mailnews/addrbook/test/unit/test_collection_2.js new file mode 100644 index 0000000000..bff3d6e916 --- /dev/null +++ b/comm/mailnews/addrbook/test/unit/test_collection_2.js @@ -0,0 +1,42 @@ +/* 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 Address Collector Service part 2. + * + * This test checks that we don't collect addresses when they already exist + * in other address books. + */ + +function run_test() { + // Test - Get the address collector + loadABFile("data/collect", kPABData.fileName); + + // Get the actual collector + var addressCollect = Cc[ + "@mozilla.org/addressbook/services/addressCollector;1" + ].getService(Ci.nsIAbAddressCollector); + + // Set the new pref afterwards to ensure we change correctly + Services.prefs.setCharPref("mail.collect_addressbook", kCABData.URI); + + // XXX Getting all directories ensures we create all ABs because the + // address collector can't currently create ABs itself (bug 314448). + MailServices.ab.directories; + + addressCollect.collectAddress("Other Book <other@book.invalid>", true); + + let PAB = MailServices.ab.getDirectory(kPABData.URI); + + var cards = PAB.childCards; + + Assert.equal(cards.length, 1); + + Assert.equal(cards[0].displayName, "Other Book"); + Assert.equal(cards[0].primaryEmail, "other@book.invalid"); + + // Check the CAB has no cards. + let CAB = MailServices.ab.getDirectory(kCABData.URI); + Assert.equal(CAB.childCards.length, 0); +} |