 describe 'spark.components.Modal', ->
 
   modal     = null
+  modalId   = null
   overlay   = null
+  overlayId = null
   fireClick = (element) ->
     event = document.createEvent 'MouseEvents'
     event.initEvent 'click', yes, yes



  it 'should be destroyable with close icon', ->
    mid = spark.utils.getUid()
    oid = spark.utils.getUid()

    modal.setDomId mid
    modal.getOverlay().setDomId oid

    expect(document.getElementById(mid)).not.toBeNull()
    expect(document.getElementById(oid)).not.toBeNull()

    closeIcon = modal.getElement().querySelector '.modal-close'
    fireClick closeIcon

    expect(document.getElementById(mid)).toBeNull()
    expect(document.getElementById(oid)).toBeNull()


  it 'should be destroyed after calling destoy method', ->
    mid = spark.utils.getUid()
    oid = spark.utils.getUid()

    modal.setDomId mid
    modal.getOverlay().setDomId oid

    expect(document.getElementById(mid)).not.toBeNull()
    expect(document.getElementById(oid)).not.toBeNull()

    modal.destroy()

    expect(document.getElementById(mid)).toBeNull()
    expect(document.getElementById(oid)).toBeNull()



  it 'should remove itself when overlay is clicked', ->
    expect(document.getElementById(modalId)).toBeDefined()

    fireClick(overlay.getElement())

    expect(document.getElementById(modalId)).toBeNull()


  it 'should emit event for preset buttons', ->
