summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/compose/test/unit/test_fcc2.js
blob: e7f8d7aadf400922b37bb58d5e5bbec5dc060fcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* 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 that when fcc2 field is set, the mail is copied to the fcc2 folder.
 */

var { MailUtils } = ChromeUtils.import("resource:///modules/MailUtils.jsm");

let fcc2Folder;

add_setup(async function () {
  localAccountUtils.loadLocalMailAccount();
  fcc2Folder = localAccountUtils.rootFolder.createLocalSubfolder("fcc2");
});

/**
 * Send a message with the fcc2 field set, then check the message in the fcc2
 * folder.
 */
add_task(async function testFcc2() {
  let CompFields = CC(
    "@mozilla.org/messengercompose/composefields;1",
    Ci.nsIMsgCompFields
  );
  let fields = new CompFields();
  fields.to = "Nobody <nobody@tinderbox.invalid>";
  fields.subject = "Test fcc2";
  fields.fcc2 = fcc2Folder.URI;
  let identity = getSmtpIdentity(
    "from@tinderbox.invalid",
    getBasicSmtpServer()
  );
  await richCreateMessage(fields, [], identity);

  // Check the message shows up correctly in the fcc2 folder.
  let msgData = mailTestUtils.loadMessageToString(
    fcc2Folder,
    mailTestUtils.firstMsgHdr(fcc2Folder)
  );
  Assert.ok(msgData.includes("Subject: Test fcc2"));
});

add_task(async function cleanup() {
  fcc2Folder.deleteSelf(null);
});