зеркало из https://github.com/electron/electron.git
spec: Test asar archive with unpacked files
This commit is contained in:
Родитель
1df033dce8
Коммит
dc82553fc3
|
@ -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
|
||||
|
|
|
@ -362,6 +362,12 @@ describe 'asar package', ->
|
|||
assert.equal data, 'file1\n'
|
||||
done()
|
||||
|
||||
it 'can request a file in package with unpacked files', (done) ->
|
||||
p = path.resolve fixtures, 'asar', 'unpack.asar', 'a.txt'
|
||||
$.get "file://#{p}", (data) ->
|
||||
assert.equal data, 'a\n'
|
||||
done()
|
||||
|
||||
it 'can request a linked file in package', (done) ->
|
||||
p = path.resolve fixtures, 'asar', 'a.asar', 'link2', 'link1'
|
||||
$.get "file://#{p}", (data) ->
|
||||
|
@ -431,3 +437,8 @@ describe 'asar package', ->
|
|||
p = path.join fixtures, 'asar', 'logo.asar', 'logo.png'
|
||||
logo = require('native-image').createFromPath p
|
||||
assert.deepEqual logo.getSize(), {width: 55, height: 55}
|
||||
|
||||
it 'reads image from asar archive with unpacked files', ->
|
||||
p = path.join fixtures, 'asar', 'unpack.asar', 'atom.png'
|
||||
logo = require('native-image').createFromPath p
|
||||
assert.deepEqual logo.getSize(), {width: 1024, height: 1024}
|
||||
|
|
Двоичный файл не отображается.
|
@ -0,0 +1 @@
|
|||
a
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 628 KiB |
Загрузка…
Ссылка в новой задаче