From 04cf441c5ae18400c6b4865b0b37a71718dc9d46 Mon Sep 17 00:00:00 2001 From: Ola Bini Date: Thu, 31 Jul 2014 19:29:33 -0300 Subject: Add web-ui based on previous code --- .../spec/dispatchers/right_pane_dispatcher.spec.js | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 web-ui/test/spec/dispatchers/right_pane_dispatcher.spec.js (limited to 'web-ui/test/spec/dispatchers/right_pane_dispatcher.spec.js') diff --git a/web-ui/test/spec/dispatchers/right_pane_dispatcher.spec.js b/web-ui/test/spec/dispatchers/right_pane_dispatcher.spec.js new file mode 100644 index 00000000..5fc7ecd7 --- /dev/null +++ b/web-ui/test/spec/dispatchers/right_pane_dispatcher.spec.js @@ -0,0 +1,90 @@ +/*global Smail */ + +describeComponent('dispatchers/right_pane_dispatcher', function () { + 'use strict'; + + describe('after initialization', function () { + beforeEach(function () { + setupComponent(); + }); + + it('listens to open compose box event and creates a compose box', function () { + var composeBox = require('mail_view/ui/compose_box'); + spyOn(composeBox, 'attachTo'); + + this.component.trigger(document, Smail.events.dispatchers.rightPane.openComposeBox); + + expect(composeBox.attachTo).toHaveBeenCalled(); + }); + + describe('no message selected', function () { + var noMessageSelectedPane; + beforeEach(function () { + noMessageSelectedPane = require('mail_view/ui/no_message_selected_pane'); + spyOn(noMessageSelectedPane, 'attachTo'); + }); + + it('listen to open no message selected event and creates a no-message-selected-pane', function () { + this.component.trigger(document, Smail.events.dispatchers.rightPane.openNoMessageSelected); + + expect(noMessageSelectedPane.attachTo).toHaveBeenCalled(); + }); + + it('sends an dispatchers.middlePane.unselect event', function () { + var unselectEvent = spyOnEvent(document, Smail.events.dispatchers.middlePane.cleanSelected); + this.component.trigger(document, Smail.events.dispatchers.rightPane.openNoMessageSelected); + + expect(unselectEvent).toHaveBeenTriggeredOn(document); + }); + + it('pushes the current state with the current tag', function () { + var pushStateEvent = spyOnEvent(document, Smail.events.router.pushState); + + this.component.attr.currentTag = 'sometag'; + this.component.trigger(document, Smail.events.dispatchers.rightPane.openNoMessageSelected); + + expect(pushStateEvent).toHaveBeenTriggeredOnAndWith(document, jasmine.objectContaining({tag: this.component.attr.currentTag })); + }); + + it('pushes the current state stating that it meant to close the right pane', function () { + var pushStateEvent = spyOnEvent(document, Smail.events.router.pushState); + + this.component.attr.currentTag = 'sometag'; + this.component.trigger(document, Smail.events.dispatchers.rightPane.openNoMessageSelected); + + expect(pushStateEvent).toHaveBeenTriggeredOnAndWith(document, jasmine.objectContaining({ isDisplayNoMessageSelected: true })); + }); + + + }); + + it('listens to open a draft and creates it', function () { + var draftBox = require('mail_view/ui/draft_box'); + spyOn(draftBox, 'attachTo'); + + this.component.trigger(document, Smail.events.dispatchers.rightPane.openDraft, { ident: '1' }); + + expect(draftBox.attachTo).toHaveBeenCalled(); + }); + }); + + describe('on initialization', function () { + var noMessageSelectedPane; + + beforeEach(function () { + noMessageSelectedPane = require('mail_view/ui/no_message_selected_pane'); + spyOn(noMessageSelectedPane, 'attachTo'); + }); + + it('opens the no message selected pane but doesnt push the state', function () { + var pushStateEvent = spyOnEvent(document, Smail.events.router.pushState); + + setupComponent(); + + expect(noMessageSelectedPane.attachTo).toHaveBeenCalled(); + expect(pushStateEvent).not.toHaveBeenTriggeredOn(document); + + }); + }); + +}); -- cgit v1.2.3