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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
  | 
define(['mail_view/data/mail_builder'], function (mailBuilder) {
  'use strict';
  describe('mail builder', function () {
    it('sets ident if passed to constructor', function() {
      var mail = mailBuilder.newMail('12345').build();
      expect(mail.ident).toBe('12345');
    });
    it('sets ident to empty if not passed to constructor', function() {
      var mail = mailBuilder.newMail().build();
      expect(mail.ident).toBe('');
    });
    it('sets the subject', function() {
      var mail = mailBuilder.newMail().subject('subject').build();
      expect(mail.header.subject).toBe('subject');
    });
    it('sets the body', function() {
      var mail = mailBuilder.newMail().body('some body text').build();
      expect(mail.body).toBe('some body text');
    });
    describe('to field', function() {
      it('adds a single address', function() {
        var mail = mailBuilder.newMail().to('foo@bar.com').build();
        expect(mail.header.to).toContain('foo@bar.com');
      });
      it('adds multiple addresses', function() {
        var mail = mailBuilder.newMail().to('foo@bar.com bar@foo.com').build();
        expect(mail.header.to).toContain('foo@bar.com');
        expect(mail.header.to).toContain('bar@foo.com');
      });
      it('accepts undefined without breaking', function() {
        var mail = mailBuilder.newMail().to(undefined).build();
        expect(mail.header.to).toEqual([]);
      });
    });
    describe('cc field', function() {
      it('adds a single address', function() {
        var mail = mailBuilder.newMail().cc('foo@bar.com').build();
        expect(mail.header.cc).toContain('foo@bar.com');
      });
      it('adds multiple addresses', function() {
        var mail = mailBuilder.newMail().cc('foo@bar.com bar@foo.com').build();
        expect(mail.header.cc).toContain('foo@bar.com');
        expect(mail.header.cc).toContain('bar@foo.com');
      });
      it('accepts undefined without breaking', function() {
        var mail = mailBuilder.newMail().cc(undefined).build();
        expect(mail.header.cc).toEqual([]);
      });
    });
    describe('bcc field', function() {
      it('adds a single address', function() {
        var mail = mailBuilder.newMail().bcc('foo@bar.com').build();
        expect(mail.header.bcc).toContain('foo@bar.com');
      });
      it('adds multiple addresses', function() {
        var mail = mailBuilder.newMail().bcc('foo@bar.com bar@foo.com').build();
        expect(mail.header.bcc).toContain('foo@bar.com');
        expect(mail.header.bcc).toContain('bar@foo.com');
      });
      it('accepts undefined without breaking', function() {
        var mail = mailBuilder.newMail().bcc(undefined).build();
        expect(mail.header.bcc).toEqual([]);
      });
    });
    it('adds arbitrary headers', function() {
      var mail = mailBuilder.newMail()
        .header('Reply-To', 'something')
        .header('In-Reply-To', '12345')
        .build();
      expect(mail.header['Reply-To']).toBe('something');
      expect(mail.header['In-Reply-To']).toBe('12345');
    });
    it('adds tag', function() {
      var mail = mailBuilder.newMail()
        .tag('tag1')
        .build();
      expect(mail.tags).toContain('tag1');
    });
  });
});
  |