Sha256: 393f1663b29c60840b6575c03ccb3209708fd227f6fe5cf55bfd567660fccfe3

Contents?: true

Size: 1.85 KB

Versions: 7

Compression:

Stored size: 1.85 KB

Contents

#= require spec_helper

describe 'test environment setup', ->

  it 'loading libraries', ->
    load_modularity()
    loadCS "/vendor/assets/javascripts/mixins/clickable.coffee"
    loadCS "/vendor/assets/javascripts/modules/button.coffee"
    loadCS "/vendor/assets/javascripts/modules/counter_button.coffee"


describe 'CounterButton', ->
  template 'button.html'

  describe 'standard button functionality', ->

    describe 'manual clicks', ->

      it 'fires when clicking on the container directly', ->
        button = new window.CounterButton('#test #button1')
        button.bind_event('clicked', (spy = jasmine.createSpy()))

        button.container.click()

        expect(spy).toHaveBeenCalled()
        expect(spy.callCount).toEqual(1)


      it 'fires when clicking embedded elements of the button', ->
        button = new window.CounterButton('#test #button2')
        button.bind_event('clicked', (spy = jasmine.createSpy()))

        button.container.find('.embedded').click()

        expect(spy).toHaveBeenCalled()
        expect(spy.callCount).toEqual(1)

    describe 'programmatic clicks', ->

      it 'programmatically clicks the button', ->
        button = new window.CounterButton('#test #button2')
        spy = jasmine.createSpy()
        button.bind_event('clicked', spy)

        button.click()

        expect(spy).toHaveBeenCalled()
        
  describe 'CounterButton specific functionality', ->

    it 'provides the click counter as the event payload', ->
      button = new window.CounterButton('#test #button1')
      button.bind_event('clicked', (spy = jasmine.createSpy()))

      button.container.click()
      button.container.click()
      button.container.click()

      expect(spy.callCount).toEqual(3)
      expect(spy.argsForCall[0][1]).toEqual(1)
      expect(spy.argsForCall[1][1]).toEqual(2)
      expect(spy.argsForCall[2][1]).toEqual(3)


Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
modularity-rails-0.8.1 spec/javascripts/modules/counter_button_spec.coffee
modularity-rails-0.8.0 spec/javascripts/modules/counter_button_spec.coffee
modularity-rails-0.7.1 spec/javascripts/modules/counter_button_spec.coffee
modularity-rails-0.7.0 spec/javascripts/modules/counter_button_spec.coffee
modularity-rails-0.6.3 spec/javascripts/modules/counter_button_spec.coffee
modularity-rails-0.6.2 spec/javascripts/modules/counter_button_spec.coffee
modularity-rails-0.6.1 spec/javascripts/modules/counter_button_spec.coffee