spec: Test asar archive with unpacked files

This commit is contained in:
Cheng Zhao 2015-03-20 19:12:59 +08:00
parent 1df033dce8
commit dc82553fc3
5 changed files with 33 additions and 0 deletions

View file

@ -110,6 +110,27 @@ describe 'protocol module', ->
assert false, 'Got error: ' + errorType + ' ' + error
protocol.unregisterProtocol 'atom-file-job'
it 'returns RequestFileJob should send file from asar archive with unpacked file', (done) ->
p = path.join __dirname, 'fixtures', 'asar', 'unpack.asar', 'a.txt'
job = new protocol.RequestFileJob(p)
handler = remote.createFunctionWithReturnValue job
protocol.registerProtocol 'atom-file-job', handler
$.ajax
url: 'atom-file-job://' + p
success: (response) ->
data = require('fs').readFileSync(p)
assert.equal response.length, data.length
buf = new Buffer(response.length)
buf.write(response)
console.log buf, data
assert buf.equals(data)
protocol.unregisterProtocol 'atom-file-job'
done()
error: (xhr, errorType, error) ->
assert false, 'Got error: ' + errorType + ' ' + error
protocol.unregisterProtocol 'atom-file-job'
describe 'protocol.isHandledProtocol', ->
it 'returns true if the scheme can be handled', ->
assert.equal protocol.isHandledProtocol('file'), true