Sha256: 34b4b806aa2bed8468615d2884ecbafee7ca6b7c5794d970f25481476422a940

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

describe "Mercury.Palette", ->

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

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

  describe "#build", ->

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

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


  describe "observed events", ->

    beforeEach ->
      @palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: fixture.el, for: $('#button')})

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

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


  describe "#position", ->

    beforeEach ->
      @palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: fixture.el, for: $('#button')})

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

Version data entries

1 entries across 1 versions & 1 rubygems

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