spec: asar: Testing getting file in web page

This commit is contained in:
Cheng Zhao 2014-09-29 16:58:54 +08:00
parent 3eaf0fe82b
commit 2bf2ad094c
2 changed files with 28 additions and 0 deletions

View file

@ -261,3 +261,30 @@ describe 'asar package', ->
p = path.join fixtures, 'asar', 'a.asar', 'not-exist'
throws = -> child_process.fork p
assert.throws throws, /ENOENT/
describe 'asar protocol', ->
it 'can request a file in package', (done) ->
p = path.resolve fixtures, 'asar', 'a.asar', 'file1'
$.get "asar:#{p}", (data) ->
assert.equal data, 'file1\n'
done()
it 'can request a linked file in package', (done) ->
p = path.resolve fixtures, 'asar', 'a.asar', 'link2', 'link1'
$.get "asar:#{p}", (data) ->
assert.equal data, 'file1\n'
done()
it 'can request a file in filesystem', (done) ->
p = path.resolve fixtures, 'asar', 'file'
$.get "asar:#{p}", (data) ->
assert.equal data, 'file\n'
done()
it 'gets 404 when file is not found', (done) ->
p = path.resolve fixtures, 'asar', 'a.asar', 'no-exist'
$.ajax
url: "asar:#{p}"
error: (err) ->
assert.equal err.status, 404
done()

1
spec/fixtures/asar/file vendored Normal file
View file

@ -0,0 +1 @@
file