Sha256: 0e8d40e082c176a5cc182ec7497a7f82adf3f8858748644466f132eb5a0c2932

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

describe "Mercury.Select", ->

  beforeEach ->
    fixture.load('mercury/select.html')
    $.fx.off = true

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

  describe "#build", ->

    it "builds an element", ->
      @select = new Mercury.Select('/blank.html', 'foo', {appendTo: fixture.el, 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('/blank.html', 'foo', {appendTo: '#select_container', for: $('#button')})
      expect($('#select_container .mercury-select').length).toEqual(1)


  describe "observed events", ->

    beforeEach ->
      @select = new Mercury.Select('/blank.html', 'foo', {appendTo: fixture.el, 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('/blank.html', 'foo', {appendTo: fixture.el, 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

1 entries across 1 versions & 1 rubygems

Version Path
kiteditor-1.0.12 spec/javascripts/mercury/select_spec.js.coffee