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
|
describeComponent('page/router', function () {
'use strict';
var fakeHistory;
describe('on router:pushState coming from a tag selection', function () {
beforeEach(function () {
fakeHistory = jasmine.createSpyObj('history', ['pushState']);
this.setupComponent({history: fakeHistory});
});
it('pushes the state with the tag and the url', function () {
$(document).trigger(Pixelated.events.router.pushState, { tag: 'inbox'});
expect(fakeHistory.pushState).toHaveBeenCalledWith(jasmine.objectContaining({ tag: 'inbox' }), '', '/#/inbox');
});
it('pushes the state with mailIdent', function () {
$(document).trigger(Pixelated.events.router.pushState, { tag: 'inbox', mailIdent: 1});
expect(fakeHistory.pushState).toHaveBeenCalledWith(jasmine.objectContaining({ tag: 'inbox', mailIdent: 1 }), '', '/#/inbox/mail/1');
});
it('pushes the state with mailIdent even if mail ident is 0 (that happens for drafts)', function () {
$(document).trigger(Pixelated.events.router.pushState, { tag: 'inbox', mailIdent: 0});
expect(fakeHistory.pushState).toHaveBeenCalledWith(jasmine.objectContaining({ tag: 'inbox', mailIdent: 0 }), '', '/#/inbox/mail/0');
});
it('pushes the state with the displayNoMessage boolean forwarded from the event', function () {
$(document).trigger(Pixelated.events.router.pushState, { tag: 'inbox', mailIdent: 0});
expect(fakeHistory.pushState).toHaveBeenCalledWith(jasmine.objectContaining({ isDisplayNoMessageSelected: false}), '', '/#/inbox/mail/0');
$(document).trigger(Pixelated.events.router.pushState, { tag: 'inbox', mailIdent: 0, isDisplayNoMessageSelected: true});
expect(fakeHistory.pushState).toHaveBeenCalledWith(jasmine.objectContaining({ isDisplayNoMessageSelected: true}), '', '/#/inbox/mail/0');
});
it('when popping a state with no tag should select tag from url', function () {
var urlParams = require('page/router/url_params');
spyOn(urlParams, 'getTag').and.returnValue('tag');
var selectTagEvent = spyOnEvent(document, Pixelated.events.ui.tag.select);
this.component.popState({ state: {tag: undefined} });
expect(selectTagEvent).toHaveBeenTriggeredOnAndWith(document, jasmine.objectContaining({ tag: 'tag'}));
});
it('when popping a state triggers the displayNoMessage pane if required', function () {
var urlParams = require('page/router/url_params');
spyOn(urlParams, 'getTag').and.returnValue('tag');
var displayNoMessageEvent = spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openNoMessageSelectedWithoutPushState);
this.component.popState({ state: {tag: undefined, isDisplayNoMessageSelected: false} });
expect(displayNoMessageEvent).not.toHaveBeenTriggeredOn(document);
this.component.popState({ state: {tag: undefined, isDisplayNoMessageSelected: true} });
expect(displayNoMessageEvent).toHaveBeenTriggeredOn(document);
});
});
});
|