protocol: adding requestHttpJob method
This commit is contained in:
parent
8b8a6aea74
commit
a5e2f8e79e
8 changed files with 195 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
assert = require 'assert'
|
||||
ipc = require 'ipc'
|
||||
http = require 'http'
|
||||
path = require 'path'
|
||||
remote = require 'remote'
|
||||
protocol = remote.require 'protocol'
|
||||
|
@ -73,6 +74,28 @@ describe 'protocol module', ->
|
|||
protocol.unregisterProtocol 'atom-error-job'
|
||||
done()
|
||||
|
||||
it 'returns RequestHttpJob should send respone', (done) ->
|
||||
server = http.createServer (req, res) ->
|
||||
res.writeHead(200, {'Content-Type': 'text/plain'})
|
||||
res.end('hello')
|
||||
server.close()
|
||||
server.listen 0, '127.0.0.1', ->
|
||||
{port} = server.address()
|
||||
url = "http://127.0.0.1:#{port}"
|
||||
job = new protocol.RequestHttpJob(url)
|
||||
handler = remote.createFunctionWithReturnValue job
|
||||
protocol.registerProtocol 'atom-http-job', handler
|
||||
|
||||
$.ajax
|
||||
url: 'atom-http-job://fake-host'
|
||||
success: (data) ->
|
||||
assert.equal data, 'hello'
|
||||
protocol.unregisterProtocol 'atom-http-job'
|
||||
done()
|
||||
error: (xhr, errorType, error) ->
|
||||
assert false, 'Got error: ' + errorType + ' ' + error
|
||||
protocol.unregisterProtocol 'atom-http-job'
|
||||
|
||||
it 'returns RequestBufferJob should send buffer', (done) ->
|
||||
data = new Buffer("hello")
|
||||
job = new protocol.RequestBufferJob(data: data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue