Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Feb 29, 2024
1 parent c7cf97e commit 14e1ddf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
44 changes: 22 additions & 22 deletions test/mail-composer/mail-composer-test.js
Expand Up @@ -10,7 +10,7 @@ describe('MailComposer unit tests', () => {
});

describe('#compile', () => {
it('should use Mixed structure with text and attachment', (t) => {
it('should use Mixed structure with text and attachment', t => {
let data = {
text: 'abc',
attachments: [
Expand All @@ -27,7 +27,7 @@ describe('MailComposer unit tests', () => {
t.mock.restoreAll();
});

it('should use Mixed structure with multiple attachments', (t) => {
it('should use Mixed structure with multiple attachments', t => {
let data = {
attachments: [
{
Expand All @@ -46,7 +46,7 @@ describe('MailComposer unit tests', () => {
t.mock.restoreAll();
});

it('should create Alternative structure with text and html', (t) => {
it('should create Alternative structure with text and html', t => {
let data = {
text: 'abc',
html: 'def'
Expand All @@ -62,7 +62,7 @@ describe('MailComposer unit tests', () => {
t.mock.restoreAll();
});

it('should create Alternative structure with text, watchHtml and html', (t) => {
it('should create Alternative structure with text, watchHtml and html', t => {
let data = {
text: 'abc',
html: 'def',
Expand All @@ -80,7 +80,7 @@ describe('MailComposer unit tests', () => {
t.mock.restoreAll();
});

it('should create Alternative structure with text, amp and html', (t) => {
it('should create Alternative structure with text, amp and html', t => {
let data = {
text: 'abc',
html: 'def',
Expand All @@ -98,7 +98,7 @@ describe('MailComposer unit tests', () => {
t.mock.restoreAll();
});

it('should create Alternative structure with text, icalEvent and html', (t) => {
it('should create Alternative structure with text, icalEvent and html', t => {
let data = {
text: 'abc',
html: 'def',
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('MailComposer unit tests', () => {
});
});

it('should create Alternative structure with text, html and cid attachment', (t) => {
it('should create Alternative structure with text, html and cid attachment', t => {
let data = {
text: 'abc',
html: 'def',
Expand All @@ -170,7 +170,7 @@ describe('MailComposer unit tests', () => {
t.mock.restoreAll();
});

it('should create Related structure with html and cid attachment', (t) => {
it('should create Related structure with html and cid attachment', t => {
let data = {
html: 'def',
attachments: [
Expand All @@ -192,7 +192,7 @@ describe('MailComposer unit tests', () => {
t.mock.restoreAll();
});

it('should create content node with only text', (t) => {
it('should create content node with only text', t => {
let data = {
text: 'def'
};
Expand All @@ -204,7 +204,7 @@ describe('MailComposer unit tests', () => {
t.mock.restoreAll();
});

it('should create content node with only an attachment', (t) => {
it('should create content node with only an attachment', t => {
let data = {
attachments: [
{
Expand Down Expand Up @@ -300,13 +300,13 @@ describe('MailComposer unit tests', () => {

let expected =
'' +
'Content-Type: multipart/alternative; boundary="--_NmP-test-Part_1"\r\n' +
'X-Processed: =?UTF-8?Q?a_really_long_header_or_value_with_non-a?=\r\n' +
' =?UTF-8?Q?scii_characters_=F0=9F=91=AE?=\r\n' +
'X-Unprocessed: a really long header or value with non-ascii characters 👮\r\n' +
'Message-ID: <zzzzzz>\r\n' +
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: multipart/alternative; boundary="--_NmP-test-Part_1"\r\n' +
'\r\n' +
'----_NmP-test-Part_1\r\n' +
'Content-Type: text/plain; charset=utf-8\r\n' +
Expand Down Expand Up @@ -388,12 +388,12 @@ describe('MailComposer unit tests', () => {
};

let expected =
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'From: test1@example.com\r\n' +
'To: test2@example.com\r\n' +
'Message-ID: <rawtest>\r\n' +
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'\r\n' +
'----_NmP-test-Part_1\r\n' +
'Content-Type: multipart/alternative; boundary="--_NmP-test-Part_2"\r\n' +
Expand Down Expand Up @@ -438,13 +438,13 @@ describe('MailComposer unit tests', () => {

let expected =
'' +
'Content-Type: text/plain; charset=utf-8\r\n' +
'From: test1@example.com\r\n' +
'To: test2@example.com\r\n' +
'Message-ID: <zzzzzz>\r\n' +
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'Content-Transfer-Encoding: 7bit\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: text/plain; charset=utf-8\r\n' +
'\r\n' +
'def\r\n';

Expand All @@ -468,7 +468,6 @@ describe('MailComposer unit tests', () => {

let expected =
'' +
'Content-Type: text/plain; charset=utf-8\r\n' +
'From: =?UTF-8?B?w4TDhMOEw4Q=?= <test1@example.com>\r\n' +
'To: =?UTF-8?Q?AAA=C3=84?= <test2@example.com>\r\n' +
'Subject: =?UTF-8?Q?def_=C3=84=C3=84=C3=84=C3=84_foo_AAA?=\r\n' +
Expand All @@ -477,6 +476,7 @@ describe('MailComposer unit tests', () => {
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'Content-Transfer-Encoding: quoted-printable\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: text/plain; charset=utf-8\r\n' +
'\r\n' +
'def =C3=84=C3=84=C3=84=C3=84 foo AAA=C3=84\r\n';

Expand All @@ -501,7 +501,6 @@ describe('MailComposer unit tests', () => {

let expected =
'' +
'Content-Type: text/plain; charset=utf-8\r\n' +
'From: =?UTF-8?Q?=C3=84=C3=84=C3=84=C3=84?= <test1@example.com>\r\n' +
'To: =?UTF-8?Q?AAA=C3=84?= <test2@example.com>\r\n' +
'Subject: =?UTF-8?Q?def_=C3=84=C3=84=C3=84=C3=84_foo_AAA?=\r\n' +
Expand All @@ -510,6 +509,7 @@ describe('MailComposer unit tests', () => {
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'Content-Transfer-Encoding: quoted-printable\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: text/plain; charset=utf-8\r\n' +
'\r\n' +
'def =C3=84=C3=84=C3=84=C3=84 foo AAA=C3=84\r\n';

Expand All @@ -534,14 +534,14 @@ describe('MailComposer unit tests', () => {

let expected =
'' +
'Content-Type: text/plain; charset=utf-8\r\n' +
'From: =?UTF-8?B?w4TDhMOEw4Q=?= <test1@example.com>\r\n' +
'To: =?UTF-8?B?QUFBw4Q=?= <test2@example.com>\r\n' +
'Subject: =?UTF-8?B?ZGVmIMOEw4TDhMOEIGZvbyBBQUHDhA==?=\r\n' +
'Message-ID: <zzzzzz>\r\n' +
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'Content-Transfer-Encoding: base64\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: text/plain; charset=utf-8\r\n' +
'\r\n' +
'ZGVmIMOEw4TDhMOEIGZvbyBBQUHDhA==\r\n';

Expand All @@ -565,14 +565,14 @@ describe('MailComposer unit tests', () => {

let expected =
'' +
'Content-Type: text/plain; charset=utf-8\r\n' +
'From: test1@example.com\r\n' +
'To: test2@example.com\r\n' +
'Bcc: test3@example.com\r\n' +
'Message-ID: <zzzzzz>\r\n' +
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'Content-Transfer-Encoding: 7bit\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: text/plain; charset=utf-8\r\n' +
'\r\n' +
'def\r\n';

Expand Down Expand Up @@ -606,10 +606,10 @@ describe('MailComposer unit tests', () => {

let expected =
'' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'Message-ID: <zzzzzz>\r\n' +
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'\r\n' +
'----_NmP-test-Part_1\r\n' +
'Content-Type: text/plain; charset=utf-8\r\n' +
Expand Down Expand Up @@ -652,10 +652,10 @@ describe('MailComposer unit tests', () => {

let expected =
'' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'Message-ID: <zzzzzz>\r\n' +
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'\r\n' +
'----_NmP-test-Part_1\r\n' +
'Content-Type: text/plain; charset=utf-8\r\n' +
Expand Down Expand Up @@ -701,10 +701,10 @@ describe('MailComposer unit tests', () => {

let expected =
'' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'Message-ID: <zzzzzz>\r\n' +
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'\r\n' +
'----_NmP-test-Part_1\r\n' +
'Content-Type: text/plain; charset=utf-8\r\n' +
Expand Down Expand Up @@ -751,10 +751,10 @@ describe('MailComposer unit tests', () => {

let expected =
'' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'Message-ID: <zzzzzz>\r\n' +
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'\r\n' +
'----_NmP-test-Part_1\r\n' +
'Content-Type: text/plain; charset=utf-8\r\n' +
Expand Down Expand Up @@ -801,12 +801,12 @@ describe('MailComposer unit tests', () => {

let expected =
'' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'From: test1@example.com\r\n' +
'To: test2@example.com\r\n' +
'Message-ID: <icaltest>\r\n' +
'Date: Sat, 21 Jun 2014 10:52:44 +0000\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'\r\n' +
'----_NmP-test-Part_1\r\n' +
'Content-Type: multipart/alternative; boundary="--_NmP-test-Part_2"\r\n' +
Expand Down
23 changes: 12 additions & 11 deletions test/mime-node/mime-node-test.js
Expand Up @@ -234,11 +234,11 @@ describe('MimeNode Tests', { timeout: 50 * 1000 }, () => {
})
.setContent('Hello world!'),
expected =
'Content-Type: text/plain\r\n' +
'Date: 12345\r\n' +
'Message-ID: <67890>\r\n' +
'Content-Transfer-Encoding: 7bit\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: text/plain\r\n' +
'\r\n' +
'Hello world!\r\n';

Expand Down Expand Up @@ -271,10 +271,10 @@ describe('MimeNode Tests', { timeout: 50 * 1000 }, () => {
'message-id': '67890'
}),
expected =
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'Date: 12345\r\n' +
'Message-ID: <67890>\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'\r\n' +
'----_NmP-test-Part_1\r\n' +
'Content-Type: text/plain\r\n' +
Expand Down Expand Up @@ -691,12 +691,12 @@ describe('MimeNode Tests', { timeout: 50 * 1000 }, () => {
})
.setContent('Hello world!'),
expected =
'Content-Type: text/plain\r\n' +
'A: b\r\n' +
'Date: zzz\r\n' +
'Message-ID: <67890>\r\n' +
'Content-Transfer-Encoding: 7bit\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: text/plain\r\n' +
'\r\n' +
'Hello world!\r\n';

Expand Down Expand Up @@ -727,7 +727,6 @@ describe('MimeNode Tests', { timeout: 50 * 1000 }, () => {
})
.setContent('Hello world!'),
expected =
'Content-Type: text/plain\r\n' +
// long folded value
'Unprepared: a ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba\r\n' +
' ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba\r\n' +
Expand All @@ -742,6 +741,7 @@ describe('MimeNode Tests', { timeout: 50 * 1000 }, () => {
'Message-ID: <67890>\r\n' +
'Content-Transfer-Encoding: 7bit\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: text/plain\r\n' +
'\r\n' +
'Hello world!\r\n';

Expand All @@ -761,11 +761,11 @@ describe('MimeNode Tests', { timeout: 50 * 1000 }, () => {
})
.setContent('Hello world!'),
expected =
'Content-Type: application/x-my-stuff\r\n' +
'Date: 12345\r\n' +
'Message-ID: <67890>\r\n' +
'Content-Transfer-Encoding: base64\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: application/x-my-stuff\r\n' +
'\r\n' +
'SGVsbG8gd29ybGQh\r\n';

Expand All @@ -785,10 +785,10 @@ describe('MimeNode Tests', { timeout: 50 * 1000 }, () => {
})
.setContent('Hello world!'),
expected =
'Content-Type: multipart/global; boundary=abc\r\n' +
'Date: 12345\r\n' +
'Message-ID: <67890>\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: multipart/global; boundary=abc\r\n' +
'\r\n' +
'Hello world!\r\n' +
'--abc--' +
Expand All @@ -811,7 +811,7 @@ describe('MimeNode Tests', { timeout: 50 * 1000 }, () => {
'message-id': '67890'
})
.setContent('Hello world!'),
expected = 'Content-Type: message/rfc822\r\nDate: 12345\r\nMessage-ID: <67890>\r\nMIME-Version: 1.0\r\n\r\nHello world!\r\n';
expected = 'Date: 12345\r\nMessage-ID: <67890>\r\nMIME-Version: 1.0\r\nContent-Type: message/rfc822\r\n\r\nHello world!\r\n';

mb.build((err, msg) => {
assert.ok(!err);
Expand Down Expand Up @@ -1428,11 +1428,11 @@ describe('MimeNode Tests', { timeout: 50 * 1000 }, () => {
.setContent('Hello world!');

let expected =
'Content-Type:\ttext/plain\r\n' +
'Date:\t12345\r\n' +
'Message-ID:\t<67890>\r\n' +
'Content-Transfer-Encoding:\t7bit\r\n' +
'MIME-Version:\t1.0\r\n' +
'Content-Type:\ttext/plain\r\n' +
'\r\n' +
'Hello\tworld!\r\n';

Expand Down Expand Up @@ -1472,11 +1472,11 @@ describe('MimeNode Tests', { timeout: 50 * 1000 }, () => {
.setContent('Hello world!');

let expected =
'Content-Type:\ttext/plain\r\n' +
'Date:\t12345\r\n' +
'Message-ID:\t<67890>\r\n' +
'Content-Transfer-Encoding:\t7bit\r\n' +
'MIME-Version:\t1.0\r\n' +
'Content-Type:\ttext/plain\r\n' +
'\r\n' +
'Hello\tworld!\r\n';

Expand Down Expand Up @@ -1538,10 +1538,11 @@ describe('MimeNode Tests', { timeout: 50 * 1000 }, () => {
msg = msg.toString();
assert.strictEqual(
msg,
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'Date: 12345\r\n' +

'Date: 12345\r\n' +
'Message-ID: <67890>\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-Type: multipart/mixed; boundary="--_NmP-test-Part_1"\r\n' +
'\r\n' +
'----_NmP-test-Part_1\r\n' +
expected +
Expand Down

0 comments on commit 14e1ddf

Please sign in to comment.