Skip to content

Commit cfd877f

Browse files
committed
add test
1 parent 6607cf4 commit cfd877f

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

lib/debugger.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ R = require 'ramda'
22
psTree = require 'ps-tree'
33
Promise = require 'bluebird'
44
{Client} = require '_debugger'
5-
{spawn} = require 'child_process'
5+
childprocess = require 'child_process'
66
{EventEmitter} = require 'events'
77
Event = require 'geval/event'
88
logger = require './logger'
@@ -40,7 +40,7 @@ class ProcessManager extends EventEmitter
4040
appArgs or ''
4141
]
4242

43-
@process = spawn nodePath, args, {
43+
@process = childprocess.spawn nodePath, args, {
4444
detached: true
4545
}
4646

spec/src/debugger-spec.coffee

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
childprocess = require 'child_process'
2+
{EventEmitter} = require 'events'
3+
{ProcessManager} = require '../../lib/debugger'
4+
Stream = require 'stream'
5+
6+
makeFakeProcess = () ->
7+
process = new EventEmitter()
8+
process.stdout = new Stream()
9+
process.stderr = new Stream()
10+
11+
return process
12+
13+
describe 'ProcessManager', ->
14+
describe '.start', ->
15+
it 'starts a process base on the atom config and if no file specify', ->
16+
17+
mapping = {
18+
'atom-node-debugger.nodePath': '/bin/node'
19+
'atom-node-debugger.appArgs': '--name'
20+
'atom-node-debugger.debugPort': 5858
21+
}
22+
23+
atomStub =
24+
workspace:
25+
getActiveTextEditor: ->
26+
getPath: -> '/path/to/file.js'
27+
config:
28+
get: (key) -> mapping[key]
29+
30+
spyOn(childprocess, 'spawn').andReturn(makeFakeProcess())
31+
32+
manager = new ProcessManager(atomStub)
33+
waitsForPromise () ->
34+
manager.start().then () ->
35+
expect(childprocess.spawn).toHaveBeenCalled()
36+
expect(childprocess.spawn).toHaveBeenCalledWith('/bin/node')

0 commit comments

Comments
 (0)