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
|
/* global Pixelated */
describeComponent('mail_view/ui/draft_box', function () {
'use strict';
var mail;
beforeEach(function () {
Pixelated.mockBloodhound();
mail = Pixelated.testData().parsedMail.simpleTextPlain;
spyOn($, 'getJSON').and.returnValue($.Deferred());
});
describe('when initializing', function () {
it('fetches the email to draft', function () {
var mailWantEvent = spyOnEvent(document, Pixelated.events.mail.want);
this.setupComponent({mailIdent: '1'});
expect(mailWantEvent).toHaveBeenTriggeredOnAndWith(document, {
mail: '1', caller: this.component
});
});
});
describe('after initialize', function () {
it('renders the compose box when mail is received', function () {
this.setupComponent({mailIdent: '1'});
var templates = require('views/templates');
spyOn(this.component, 'render');
this.component.trigger(this.component, Pixelated.events.mail.here, { mail: mail});
expect(this.component.render).toHaveBeenCalledWith(templates.compose.box, {
recipients: { to: mail.header.to, cc: mail.header.cc, bcc: mail.header.bcc },
subject: mail.header.subject, attachments: [],
body: mail.textPlainBody
});
});
});
it('shows no message selected pane when draft is sent', function() {
var openNoMessageSelectedEvent = spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openNoMessageSelected);
this.setupComponent({mailIdent: mail.ident});
this.component.trigger(this.component, Pixelated.events.mail.here, { mail: mail});
this.component.trigger(document, Pixelated.events.mail.sent);
expect(openNoMessageSelectedEvent).toHaveBeenTriggeredOn(document);
});
it('should call the enableFloatlabel method when events.mail.here is trigged', function() {
this.setupComponent({mailIdent: mail.ident});
spyOn(this.component, 'enableFloatlabel');
this.component.trigger(this.component, Pixelated.events.mail.here, { mail: mail });
expect(this.component.enableFloatlabel).toHaveBeenCalledWith('input.floatlabel');
expect(this.component.enableFloatlabel).toHaveBeenCalledWith('textarea.floatlabel');
});
});
|