]> khamidou — GitHub mirrors - electron.git/commitdiff
spec: asar: fs.readFile
authorCheng Zhao <zcbenz@gmail.com>
Sun, 28 Sep 2014 15:36:45 +0000 (23:36 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 28 Sep 2014 15:36:45 +0000 (23:36 +0800)
spec/asar-spec.coffee

index 397255581825420f22b2fd5248b8e0f0e161697e..5ac58aeed3ce16889e98669120f40a4c1b037744 100644 (file)
@@ -29,3 +29,28 @@ describe 'asar package', ->
         p = path.join fixtures, 'asar', 'a.asar', 'not-exist'
         throws = -> fs.readFileSync p
         assert.throws throws, /ENOENT/
+
+    describe 'fs.readFile', ->
+      it 'reads a normal file', (done) ->
+        p = path.join fixtures, 'asar', 'a.asar', 'file1'
+        fs.readFile p, (err, content) ->
+          assert.equal String(content), 'file1\n'
+          done()
+
+      it 'reads a linked file', (done) ->
+        p = path.join fixtures, 'asar', 'a.asar', 'link1'
+        fs.readFile p, (err, content) ->
+          assert.equal String(content), 'file1\n'
+          done()
+
+      it 'reads a file from linked directory', (done) ->
+        p = path.join fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1'
+        fs.readFile p, (err, content) ->
+          assert.equal String(content), 'file1\n'
+          done()
+
+      it 'throws ENOENT error when can not find a file', (done) ->
+        p = path.join fixtures, 'asar', 'a.asar', 'not-exist'
+        fs.readFile p, (err, content) ->
+          assert.equal err.code, 'ENOENT'
+          done()