 describe "Bacon.fromEventTarget", ->
   it "should create EventStream from DOM object", ->
     emitter = new EventEmitter()
-    element =
-      addEventListener: (event, handler) ->
-        emitter.on event, handler
-        emitter.emit 'click', "x"
-      removeEventListener: (event, handler) ->
-        emitter.removeListener(event, handler)
+    emitter.on "newListener", ->
+      runs ->
+        emitter.emit "click", "x"
+
+    element = toEventTarget emitter
 
     expectStreamEvents(
       -> Bacon.fromEventTarget(element, "click").take(1)

  filter hasValue, xs
hasValue = (x) ->
  toValue(x) != "<error>"

      -> Bacon.fromEventTarget(emitter, "data").take(1)
      ["x"]
    )

  it "should clean up event listeners from EventEmitter", ->
    emitter = new EventEmitter()
    Bacon.fromEventTarget(emitter, "data").take(1).subscribe ->
    emitter.emit "data", "x"
    expect(emitter.listeners("data").length).toEqual(0)

  it "should clean up event listeners from DOM object", ->
    emitter = new EventEmitter()
    element = toEventTarget emitter
    dispose = Bacon.fromEventTarget(element, "click").subscribe ->
    dispose()
    expect(emitter.listeners("click").length).toEqual(0)

describe "EventStream.filter", -> 
  it "should filter values", ->
