forked from kiddkai/atom-node-debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugger-spec.coffee
More file actions
43 lines (36 loc) · 1.62 KB
/
Copy pathdebugger-spec.coffee
File metadata and controls
43 lines (36 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
childprocess = require 'child_process'
{EventEmitter} = require 'events'
{ProcessManager} = require '../../lib/debugger'
Stream = require 'stream'
makeFakeProcess = () ->
process = new EventEmitter()
process.stdout = new Stream()
process.stderr = new Stream()
return process
describe 'ProcessManager', ->
describe '.start', ->
it 'starts a process base on the atom config and if no file specify', ->
mapping = {
'node-debugger.nodePath': '/path/to/node'
'node-debugger.appArgs': '--name'
'node-debugger.debugPort': 5860
}
atomStub =
project:
resolvePath: (file) -> '/path/to/file.js'
workspace:
getActiveTextEditor: ->
getPath: -> '/path/to/file.js'
config:
get: (key) -> mapping[key]
spyOn(childprocess, 'spawn').andReturn(makeFakeProcess())
manager = new ProcessManager(atomStub)
waitsForPromise () ->
manager.start().then () ->
expect(childprocess.spawn).toHaveBeenCalled()
# expect(childprocess.spawn).toHaveBeenCalledWith('/path/to/node', ['--debug-brk=5860', '/path/to/file.js', '--name', { detached : true }])
# cannot get the toHaveBeenCalledWith to match the arguments so this method is used instead to verify the call
expect(childprocess.spawn.mostRecentCall.args[0]).toEqual('/path/to/node')
expect(childprocess.spawn.mostRecentCall.args[1][0]).toEqual('--debug-brk=5860')
expect(childprocess.spawn.mostRecentCall.args[1][1]).toEqual('/path/to/file.js')
expect(childprocess.spawn.mostRecentCall.args[1][2]).toEqual('--name')