mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Add spec for Task.once()
This commit is contained in:
parent
2a7d35cc39
commit
8c4bddac9f
3
spec/fixtures/task-spec-handler.coffee
vendored
Normal file
3
spec/fixtures/task-spec-handler.coffee
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = ->
|
||||
console.log "The pid is #{process.pid}"
|
||||
'hello'
|
@ -20,3 +20,23 @@ describe "Task", ->
|
||||
expect(console.log).not.toHaveBeenCalled()
|
||||
expect(console.error).not.toHaveBeenCalled()
|
||||
expect(console.warn).not.toHaveBeenCalled()
|
||||
|
||||
describe "@once(taskPath, args..., callback)", ->
|
||||
it "terminates the process after it completes", ->
|
||||
handlerResult = null
|
||||
task = Task.once 'fixtures/task-spec-handler', (result) ->
|
||||
handlerResult = result
|
||||
|
||||
processClosed = false
|
||||
processErrored = false
|
||||
childProcess = task.childProcess
|
||||
spyOn(childProcess, 'kill').andCallThrough()
|
||||
task.childProcess.on 'error', -> processErrored = true
|
||||
|
||||
waitsFor ->
|
||||
handlerResult?
|
||||
|
||||
runs ->
|
||||
expect(handlerResult).toBe 'hello'
|
||||
expect(childProcess.kill).toHaveBeenCalled()
|
||||
expect(processErrored).toBe false
|
||||
|
Loading…
Reference in New Issue
Block a user