 
 
   it 'should remove itself when overlay is clicked', ->
-    modal.setDomId 'modally'
+    expect(document.getElementById(modalId)).toBeDefined()
 
-    expect(document.getElementById('modally')).toBeDefined()
+    fireClick(overlay.getElement())
 
-    fireClick(overlay)
-
-    expect(document.getElementById('modally')).toBeNull()
+    expect(document.getElementById(modalId)).toBeNull()
 
 
   it 'should emit event for preset buttons', ->



  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()

    m = new spark.components.Modal blocking: yes
    o = m.getOverlay()

    fireClick o.getElement()

    expect(document.getElementById(overlayId)).not.toBeNull()

    m.removeFromDocument()

