Skip to content

Instantly share code, notes, and snippets.

@juliobetta
Forked from webgio/JasmineSpec.coffee
Created February 12, 2014 15:59
Show Gist options
  • Save juliobetta/8958275 to your computer and use it in GitHub Desktop.
Save juliobetta/8958275 to your computer and use it in GitHub Desktop.
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()
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