summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/local/test/unit/test_preview.js
blob: 83cfce256bef079d7ae01237f37705224f5c6399 (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
var bugmail10 = do_get_file("../../../data/bugmail10");
var bugmail11 = do_get_file("../../../data/bugmail11");
var bugmail10_preview =
  "Do not reply to this email. You can add comments to this bug at https://bugzilla.mozilla.org/show_bug.cgi?id=436880 -- Configure bugmail: https://bugzilla.mozilla.org/userprefs.cgi?tab=email ------- You are receiving this mail because: -----";
var bugmail11_preview =
  "Bugzilla has received a request to create a user account using your email address (example@example.org). To confirm that you want to create an account using that email address, visit the following link: https://bugzilla.mozilla.org/token.cgi?t=xxx";

function run_test() {
  do_test_pending();
  copyFileMessageInLocalFolder(bugmail10, 0, "", null, copy_next_message);
}

function copy_next_message(aMessageHeaderKeys, aStatus) {
  copyFileMessageInLocalFolder(bugmail11, 0, "", null, test_preview);
}

function test_preview(aMessageHeaderKeys, aStatus) {
  let headerKeys = aMessageHeaderKeys;
  Assert.notEqual(headerKeys, null);
  Assert.equal(headerKeys.length, 2);
  try {
    localAccountUtils.inboxFolder.fetchMsgPreviewText(headerKeys, null);
    Assert.equal(
      localAccountUtils.inboxFolder
        .GetMessageHeader(headerKeys[0])
        .getStringProperty("preview"),
      bugmail10_preview
    );
    Assert.equal(
      localAccountUtils.inboxFolder
        .GetMessageHeader(headerKeys[1])
        .getStringProperty("preview"),
      bugmail11_preview
    );
  } catch (ex) {
    dump(ex);
    do_throw(ex);
  }
  do_test_finished();
}