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
|
/*global Pixelated */
require(['services/model/mail'], function (Mail) {
'use strict';
describe('services/model/mail', function () {
describe('parsing', function () {
describe('a single email', function () {
var sentMail, draftMail, recievedMail, recievedMailWithCC, rawMailWithMultipleTo;
beforeEach(function () {
sentMail = Mail.create(Pixelated.testData().rawMail.sent);
draftMail = Mail.create(Pixelated.testData().rawMail.draft);
recievedMail = Mail.create(Pixelated.testData().rawMail.recieved);
recievedMailWithCC = Mail.create(Pixelated.testData().rawMail.recievedWithCC);
rawMailWithMultipleTo = Mail.create(Pixelated.testData().rawMail.rawMailWithMultipleTo);
});
it('correctly identifies a sent mail', function () {
expect(sentMail.isSentMail()).toBe(true);
});
it('correctly identifies a draft mail', function () {
expect(draftMail.isDraftMail()).toBe(true);
});
it('correctly identifies a recieved mail', function () {
expect(recievedMail.isSentMail()).toBe(false);
expect(recievedMail.isDraftMail()).toBe(false);
});
});
describe('multipart email', function () {
var parsedMultipartMail;
beforeEach(function () {
parsedMultipartMail = Mail.create(Pixelated.testData().rawMail.multipart);
});
it('parses the mail as multipart/alternative', function () {
expect(parsedMultipartMail.isMailMultipartAlternative()).toBe(true);
});
it('lists the correct available content-type of the parts', function () {
expect(parsedMultipartMail.availableBodyPartsContentType()).toEqual(['text/plain;', 'text/html;']);
});
it('gets the list of parts', function () {
var expectedParts = [
{
headers: { 'Content-Type': 'text/plain;' },
body: 'Hello everyone!\n'
},
{
headers: {
'Content-Type': 'text/html;',
'Content-Transfer-Encoding': 'quoted-printable'
},
body: '<p><b>Hello everyone!</b></p>\n'
}
];
expect(parsedMultipartMail.getMailMultiParts()).toEqual(expectedParts);
});
it('gets the text/plain body by the content-type', function () {
expect(parsedMultipartMail.getMailPartByContentType('text/plain;')).toEqual(
{
headers: { 'Content-Type': 'text/plain;' },
body: 'Hello everyone!\n'
});
});
it('parses the content type of a text/html body', function () {
expect(parsedMultipartMail.getMailPartByContentType('text/html;')).toEqual({
headers: {
'Content-Type': 'text/html;',
'Content-Transfer-Encoding': 'quoted-printable'
},
body: '<p><b>Hello everyone!</b></p>\n'
});
});
});
});
});
});
|