Sha256: a7cb62fde4fdd4dbb85cabaef18e39140a934056e4412f48cddf7ee48d8b778e

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require '/assets/mercury/mercury.js'

describe "Mercury.dialogHandlers.forecolor", ->

  template 'mercury/dialogs/forecolor.html'

  beforeEach ->
    @dialog = {element: $('#test'), button: $('#button')}
    Mercury.dialogHandlers.forecolor.call(@dialog)

  describe "when a .picker or .last-picked element is clicked", ->

    it "sets the last picked color to whatever was selected", ->
      $('.last-picked').css({background: '#0000FF'})
      jasmine.simulate.click($('#white').get(0))
      expect($('.last-picked').css('backgroundColor')).toEqual('rgb(255, 255, 255)')
      jasmine.simulate.click($('#red').get(0))
      expect($('.last-picked').css('backgroundColor')).toEqual('rgb(255, 0, 0)')

    it "sets the background color of the button", ->
      $('#button').css({background: '#0000FF'})
      jasmine.simulate.click($('#white').get(0))
      expect($('#button').css('backgroundColor')).toEqual('rgb(255, 255, 255)')
      jasmine.simulate.click($('#red').get(0))
      expect($('#button').css('backgroundColor')).toEqual('rgb(255, 0, 0)')

    it "triggers an action", ->
      spy = spyOn(Mercury, 'trigger').andCallFake(=>)
      jasmine.simulate.click($('#white').get(0))
      expect(spy.callCount).toEqual(1)
      expect(spy.argsForCall[0]).toEqual(['action', {action: 'forecolor', value: 'rgb(255, 255, 255)'}])


  describe "when any other element is clicked", ->

    it "does nothing", ->
      spy = spyOn(Mercury, 'trigger').andCallFake(=>)
      jasmine.simulate.click($('#green').get(0))
      expect(spy.callCount).toEqual(0)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mercury-rails-0.1.1 spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee