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 pathmailRouter.spec.js
88 lines (60 loc) · 1.9 KB
/
mailRouter.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
describe("mail router", function(){
"use strict";
var router, startMail, inbox;
beforeEach(function(){
startHistory();
startMail = spyOn(BBCloneMail, "startSubApp");
inbox = BBCloneMail.module("MailApp.Inbox");
router = BBCloneMail.module("MailRouter");
router.start();
});
afterEach(function(){
router.stop();
delete inbox.controller;
});
function mockControllerMethod(methodName){
var spy = jasmine.createSpy(methodName);
inbox.controller = {};
inbox.controller[methodName] = spy;
return spy;
}
describe("when navigating to the inbox (empty route)", function(){
var showInbox;
beforeEach(function(){
showInbox = mockControllerMethod("showInbox");
Backbone.history.loadUrl("");
});
it("should start the mail app", function(){
expect(startMail).toHaveBeenCalledWith("MailApp");
});
it("should show the inbox", function(){
expect(showInbox).wasCalled();
});
});
describe("when routing to an individual email", function(){
var showMailById;
beforeEach(function(){
showMailById = mockControllerMethod("showMailById");
Backbone.history.loadUrl("inbox/mail/1");
});
it("should start the mail app", function(){
expect(startMail).toHaveBeenCalledWith("MailApp");
});
it("should show the email by id", function(){
expect(showMailById).toHaveBeenCalled();
});
});
describe("when navigating to a mail category", function(){
var showMailByCategory;
beforeEach(function(){
showMailByCategory = mockControllerMethod("showMailByCategory");
Backbone.history.loadUrl("categories/foo");
});
it("should start the mail app", function(){
expect(startMail).toHaveBeenCalledWith("MailApp");
});
it("should show the email by category", function(){
expect(showMailByCategory).toHaveBeenCalled();
});
});
});