This repository was archived by the owner on Oct 10, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathmailbox.spec.js
95 lines (67 loc) · 2.18 KB
/
mailbox.spec.js
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
describe("mailbox", function(){
"use strict";
describe("when showing an email collection", function(){
var mailbox, email;
beforeEach(function(){
affix("#email-preview-template div");
affix("article#main");
mailbox = BBCloneMail.module("MailApp.Mailbox");
mailbox.start();
email = new Backbone.Collection([{}]);
BBCloneMail.execute("show:mail:list", email);
});
afterEach(function(){
mailbox.stop();
});
it("should show the mail", function(){
var el = $("#main .email-list li");
expect(el.length).toBe(1);
});
});
describe("when clicking an email preview", function(){
var mailbox, view, email;
beforeEach(function(){
startHistory();
affix("#email-preview-template div");
affix("#email-view-template li");
affix("article#main");
email = new Backbone.Model();
var emailList = new Backbone.Collection([email]);
mailbox = BBCloneMail.module("MailApp.Mailbox");
mailbox.start();
spyOn(mailbox.controller, "showMailItem").andCallThrough();
BBCloneMail.execute("show:mail:list", emailList);
var el = $("#main .email-list li");
el.trigger("click");
});
afterEach(function(){
mailbox.stop();
});
it("should show the selected email", function(){
expect(mailbox.controller.showMailItem).toHaveBeenCalledWith(email);
});
});
describe("when showing an individual email", function(){
var mailbox, email;
beforeEach(function(){
startHistory();
affix("article#main; #email-view-template li");
BBCloneMail.main.reset();
BBCloneMail.main.ensureEl();
mailbox = BBCloneMail.module("MailApp.Mailbox");
mailbox.start();
email = new Backbone.Model({id: 1});
BBCloneMail.execute("show:mail:item", email);
});
afterEach(function(){
mailbox.stop();
});
it("should show the full email contents", function(){
var el = $("#main .email-list li");
expect(el.length).toBe(1);
});
it("should route to that email", function(){
expect(window.location.hash).toBe("#inbox/mail/" + email.id);
});
});
});