summaryrefslogtreecommitdiff
path: root/web-ui/test
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/test')
-rw-r--r--web-ui/test/spec/helpers/view_helper.spec.js20
-rw-r--r--web-ui/test/spec/mail_list/ui/mail_items/draft_item.spec.js32
-rw-r--r--web-ui/test/spec/mail_list/ui/mail_items/generic_mail_item.spec.js2
-rw-r--r--web-ui/test/spec/mail_list/ui/mail_items/mail_item.spec.js1
-rw-r--r--web-ui/test/test_data.js35
5 files changed, 79 insertions, 11 deletions
diff --git a/web-ui/test/spec/helpers/view_helper.spec.js b/web-ui/test/spec/helpers/view_helper.spec.js
index 920709b2..655ba181 100644
--- a/web-ui/test/spec/helpers/view_helper.spec.js
+++ b/web-ui/test/spec/helpers/view_helper.spec.js
@@ -25,25 +25,29 @@ define(['helpers/view_helper'], function (viewHelper) {
});
});
- describe('getFormmattedDate', function() {
+ describe('formatDate', function() {
+ var template;
+ beforeEach(function () {
+ template = Handlebars.compile('{{formatDate date}}');
+ });
+
it('formats correctly a Date for today', function() {
var d = new Date();
- var dtest = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 14, 2, 36);
-
- var res = viewHelper.getFormattedDate(dtest);
+ var mailDate = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 14, 2, 36);
- expect(res).toEqual('14:02');
+ var result = template({ date: mailDate.toISOString() });
+ expect(result).toEqual('14:02');
});
it('formats correctly a Date for a specific day', function() {
- var dtest = new Date(2013, 2, 13, 7, 56, 1);
+ var mailDate = new Date(2013, 2, 13, 7, 56, 1);
- var res = viewHelper.getFormattedDate(dtest);
+ var result = template({ date: mailDate.toISOString() });
// This expectation is weird for the month - JS Dates have date numbers be zero-indexed, thus the discrepancy
// Specifically, the 2 in the constructor DOES match the 3 in the expectation below.
- expect(res).toEqual('2013-03-13');
+ expect(result).toEqual('2013-03-13');
});
});
diff --git a/web-ui/test/spec/mail_list/ui/mail_items/draft_item.spec.js b/web-ui/test/spec/mail_list/ui/mail_items/draft_item.spec.js
new file mode 100644
index 00000000..fbe285c6
--- /dev/null
+++ b/web-ui/test/spec/mail_list/ui/mail_items/draft_item.spec.js
@@ -0,0 +1,32 @@
+describeComponent('mail_list/ui/mail_items/draft_item', function () {
+ 'use strict';
+
+ var mail;
+
+ beforeEach(function () {
+ mail = Pixelated.testData().parsedMail.draft;
+
+ this.setupComponent('<li></li>', {
+ mail: mail,
+ selected: false,
+ templateType: 'single'
+ });
+ });
+
+ it('should de-select the item if a new mail is composed', function () {
+ this.component.$node.addClass('selected');
+
+ $(document).trigger(Pixelated.events.ui.composeBox.newMessage);
+
+ expect(this.component.$node).not.toHaveClass('selected');
+ });
+
+ it('should trigger the openDraft event when clicked', function () {
+ var openDraftEvent = spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openDraft);
+
+ this.$node.find('a').click();
+
+ expect(openDraftEvent).toHaveBeenTriggeredOnAndWith(document, { ident: 'B2432' });
+ });
+});
+
diff --git a/web-ui/test/spec/mail_list/ui/mail_items/generic_mail_item.spec.js b/web-ui/test/spec/mail_list/ui/mail_items/generic_mail_item.spec.js
index 88735302..87d38595 100644
--- a/web-ui/test/spec/mail_list/ui/mail_items/generic_mail_item.spec.js
+++ b/web-ui/test/spec/mail_list/ui/mail_items/generic_mail_item.spec.js
@@ -7,11 +7,11 @@ describeComponent('mail_list/ui/mail_items/generic_mail_item', function () {
mail = Pixelated.testData().parsedMail.simpleTextPlain;
mail.tags = [];
mail.mailbox = 'inbox';
+ mail.currentTag = 'inbox';
this.setupComponent('<li></li>', {
mail: mail,
selected: false,
- tag: 'inbox',
templateType: 'single'
});
});
diff --git a/web-ui/test/spec/mail_list/ui/mail_items/mail_item.spec.js b/web-ui/test/spec/mail_list/ui/mail_items/mail_item.spec.js
index b1ac3037..03f95e54 100644
--- a/web-ui/test/spec/mail_list/ui/mail_items/mail_item.spec.js
+++ b/web-ui/test/spec/mail_list/ui/mail_items/mail_item.spec.js
@@ -10,7 +10,6 @@ describeMixin('mail_list/ui/mail_items/mail_item', function () {
selected: false,
tag: 'inbox'
});
- this.component.attachListeners();
});
describe('mail checkbox', function () {
diff --git a/web-ui/test/test_data.js b/web-ui/test/test_data.js
index f09260c9..446fd7c6 100644
--- a/web-ui/test/test_data.js
+++ b/web-ui/test/test_data.js
@@ -170,6 +170,38 @@ define(function() {
}
};
+ var draftMail = {
+ status: [],
+ header: {'from': 'jed_waelchi@cummerata.info',
+ cc: [],
+ bcc: [],
+ to: [],
+ date: '2015-04-09T18:30:18.998999-03:00',
+ subject: 'bla'},
+ ident: 'B2432',
+ replying: {'single': 'jed_waelchi@cummerata.info',
+ all: {
+ 'to-field': ['jed_waelchi@cummerata.info'],
+ 'cc-field': []
+ }
+ },
+ attachments: [],
+ textPlainBody: 'bla',
+ tags: [],
+ htmlBody: null,
+ mailbox: 'drafts',
+ security_casing: {'locks': [],
+ imprints: [{'state': 'no_signature_information'}]
+ },
+ isSentMail: function() { return false; },
+ isDraftMail: function() { return false; },
+ replyToAddress: function() { return { to: ['jed_waelchi@cummerata.info'], cc: [] }; },
+ replyToAllAddress: function() { return { to: ['jed_waelchi@cummerata.info'], cc: [] }; },
+ isMailMultipartAlternative: function () { return false; },
+ availableBodyPartsContentType: function () { return []; },
+ getMailPartByContentType: function () { return; }
+ };
+
var testData = {
rawMail: {
mail: rawMail,
@@ -182,7 +214,8 @@ define(function() {
},
parsedMail: {
simpleTextPlain: simpleTextPlainMail,
- html: htmlNoEncodingMail
+ html: htmlNoEncodingMail,
+ draft: draftMail
}
};