Sha256: ef4d57a664475743c721afd220cde863dc6035992f9ff873eb91401ff09c6cb1

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 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 modularity.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 modularity.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 modularity.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 modularity.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

1 entries across 1 versions & 1 rubygems

Version Path
modularity-rails-0.9.0 spec/javascripts/modules/counter_button_spec.coffee