Sha256: 88409cc463a60c99ceed187e46887a84b29e3f0248633162bfffed1c99e697d6

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

require '/assets/mercury.js'

describe "Mercury.Select", ->

  template 'mercury/select.html'

  beforeEach ->
    $.fx.off = true

  afterEach ->
    @select = null
    delete(@select)

  describe "#build", ->

    it "builds an element", ->
      @select = new Mercury.Select('/evergreen/responses/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
      html = $('<div>').html(@select.element).html()
      expect(html).toContain('class="mercury-select mercury-foo-select loading"')
      expect(html).toContain('style="display:none"')

    it "appends to any element", ->
      @select = new Mercury.Select('/evergreen/responses/blank.html', 'foo', {appendTo: '#select_container', for: $('#button')})
      expect($('#select_container .mercury-select').length).toEqual(1)


  describe "observed events", ->

    beforeEach ->
      @select = new Mercury.Select('/evergreen/responses/blank.html', 'foo', {appendTo: '#test', for: $('#button')})

    it "hides", ->
      @select.element.css({display: 'block'})
      Mercury.trigger('hide:dialogs')
      expect(@select.element.css('display')).toEqual('none')

    it "doesn't hide if it's the same dialog", ->
      @select.element.css({display: 'block'})
      Mercury.trigger('hide:dialogs', @select)
      expect(@select.element.css('display')).toEqual('block')


  describe "#position", ->

    beforeEach ->
      @select = new Mercury.Select('/evergreen/responses/blank.html', 'foo', {appendTo: '#test', for: $('#button')})

    it "positions based on it's button", ->
      @select.element.css({display: 'block'})
      @select.position(true)
      expect(@select.element.offset()).toEqual({top: 20, left: 42})

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mercury-rails-0.2.3 spec/javascripts/mercury/select_spec.js.coffee
mercury-rails-0.2.0 spec/javascripts/mercury/select_spec.js.coffee