-
-
Save juliobetta/8958275 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'App.HeaderModule', -> | |
beforeEach -> | |
@headerModule = window.App.HeaderModule | |
it 'should exist', -> | |
expect(@headerModule).not.toBeUndefined() | |
describe 'starting', -> | |
beforeEach -> | |
@stubbedController = { show: => @calledShow = true } | |
@headerControllerStub = sinon.stub window.App.HeaderModule, "HeaderController" | |
@headerControllerStub.returns @stubbedController | |
@headerModule.start() | |
afterEach -> | |
@headerControllerStub.restore() | |
@headerModule.stop() | |
it 'should create the controller with App.headerRegion', -> | |
expect(@headerControllerStub).toHaveBeenCalledWith {region: window.App.headerRegion} | |
it 'should make the controller show', -> | |
expect(@calledShow).toBeTruthy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HeaderModule = App.module 'HeaderModule' | |
class HeaderView extends Marionette.CompositeView | |
class HeaderController extends Marionette.Controller | |
initialize: (options) -> | |
@region = options.region | |
show: -> | |
model = new Backbone.Model() | |
view = new HeaderModule.HeaderView { model } | |
@region.show(view) | |
HeaderModule.addInitializer -> | |
@controller = new HeaderModule.HeaderController { region: App.headerRegion } | |
@controller.show() | |
HeaderModule.export HeaderController, HeaderView |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment