Sha256: 747e6f92fe199ad3b6ba6da6f4b1fb2b93aebfc3e2aed84afa1e70100d725bdb

Contents?: true

Size: 1.85 KB

Versions: 21

Compression:

Stored size: 1.85 KB

Contents

#= require presenters/examples_presenter

describe "ExamplesPresenter", ->
  before ->
    @presenter = new ExamplesPresenter()

  it "should have presenterName 'examples'", ->
    expect(@presenter.presenterName).to.equal("examples")

  it "should have modelName 'example'", ->
    expect(@presenter.modelName).to.equal("example")

  describe "action trigger", ->
    it "#index", ->
      spy = sinon.spy(@presenter, 'index')

      $(document).trigger('ujs:examples:index', 'blah')
      expect(spy).to.have.been.calledOnce

      spy.restore()

    it "#show", ->
      spy = sinon.spy(@presenter, 'show')

      $(document).trigger('ujs:examples:show', 'blah')
      expect(spy).to.have.been.calledOnce

      spy.restore()

  describe "no action", ->
    it "#new", ->
      spy = sinon.spy(@presenter, 'new')

      $(document).trigger('ujs:examples:new', 'blah')
      expect(spy).to.not.have.been.called

      spy.restore()

  describe "#beforeFilters", ->
    before ->
      @spy = sinon.spy(@presenter, 'beforeFilter')
      $(document).trigger('ujs:examples:index', 'response')

    after ->
      @spy.restore()

    it "should run beforeFilter", ->
      expect(@spy).to.have.been.calledOnce

    it "#response should be 'response'", ->
      expect(@presenter.response).to.equal('response')

    it "#params should be Object", ->
      expect(@presenter.params).to.be.an.instanceof(Object)

  describe "#elify", ->
    it "should run elify", ->
      spy = sinon.spy(@presenter, 'elify')

      $(document).trigger('ujs:examples:index', 'response')
      expect(spy).to.have.been.calledOnce

      spy.restore()

  describe "#afterFilter", ->
    before ->
      @spy = sinon.spy(@presenter, 'afterFilter')
      $(document).trigger('ujs:examples:index', 'response')

    after ->
      @spy.restore()

    it "should run afterFilter", ->
      expect(@spy).to.have.been.calledOnce

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
transponder-2.0.0 spec/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-1.0.0 spec/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.10.4 spec/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.10.2 spec/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.10.1 spec/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.9.6 spec/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.9.5 spec/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.9.4 spec/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.9.3 spec/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.9.2 spec/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.9.0 test/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.8.2 test/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.1.5 test/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.1.4 test/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.1.3 test/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.1.2 test/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.1.1 test/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.1.0 test/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.0.8 test/javascripts/transponder/presenters/examples_presenter_test.coffee
transponder-0.0.7 test/javascripts/transponder/presenters/examples_presenter_test.coffee