]> khamidou — GitHub mirrors - electron.git/commitdiff
spec: asar: Testing getting file in web page
authorCheng Zhao <zcbenz@gmail.com>
Mon, 29 Sep 2014 08:58:54 +0000 (16:58 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 29 Sep 2014 08:58:54 +0000 (16:58 +0800)
spec/asar-spec.coffee
spec/fixtures/asar/file [new file with mode: 0644]

index e1286f93cee9154191ebaf18e3a1ab12000906f1..0144b9a947f0dbf0a1a917431ad855b7184beb64 100644 (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()
diff --git a/spec/fixtures/asar/file b/spec/fixtures/asar/file
new file mode 100644 (file)
index 0000000..f73f309
--- /dev/null
@@ -0,0 +1 @@
+file