Add specs for Task events
Signed-off-by: Nathan Sobo <nathan@github.com>
Esse commit está contido em:
@@ -1,2 +1,3 @@
|
|||||||
module.exports = ->
|
module.exports = ->
|
||||||
|
emit("some-event", 1, 2, 3)
|
||||||
'hello'
|
'hello'
|
||||||
|
|||||||
@@ -20,3 +20,26 @@ describe "Task", ->
|
|||||||
expect(handlerResult).toBe 'hello'
|
expect(handlerResult).toBe 'hello'
|
||||||
expect(childProcess.kill).toHaveBeenCalled()
|
expect(childProcess.kill).toHaveBeenCalled()
|
||||||
expect(processErrored).toBe false
|
expect(processErrored).toBe false
|
||||||
|
|
||||||
|
it "calls listeners registered with ::on when events are emitted in the task", ->
|
||||||
|
task = new Task(require.resolve('./fixtures/task-spec-handler'))
|
||||||
|
|
||||||
|
eventSpy = jasmine.createSpy('eventSpy')
|
||||||
|
task.on("some-event", eventSpy)
|
||||||
|
|
||||||
|
waitsFor (done) -> task.start(done)
|
||||||
|
|
||||||
|
runs ->
|
||||||
|
expect(eventSpy).toHaveBeenCalledWith(1, 2, 3)
|
||||||
|
|
||||||
|
it "unregisters listeners when the Disposable returned by ::on is disposed", ->
|
||||||
|
task = new Task(require.resolve('./fixtures/task-spec-handler'))
|
||||||
|
|
||||||
|
eventSpy = jasmine.createSpy('eventSpy')
|
||||||
|
disposable = task.on("some-event", eventSpy)
|
||||||
|
disposable.dispose()
|
||||||
|
|
||||||
|
waitsFor (done) -> task.start(done)
|
||||||
|
|
||||||
|
runs ->
|
||||||
|
expect(eventSpy).not.toHaveBeenCalled()
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário