From 034dc8c16654e318dbb2d9111d6a13e61a54d903 Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Sat, 9 Nov 2013 15:12:07 -0500 Subject: [PATCH] Add test for invalid path to readFile. --- tests/spec/idbfs.spec.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/spec/idbfs.spec.js b/tests/spec/idbfs.spec.js index 9165274..d4f96d0 100644 --- a/tests/spec/idbfs.spec.js +++ b/tests/spec/idbfs.spec.js @@ -730,6 +730,29 @@ describe('fs.writeFile, fs.readFile', function() { expect(typeof this.fs.readFile).toEqual('function'); }); + it('should error when path is wrong to readFile', function() { + var complete = false; + var _error, _result; + var that = this; + + var contents = "This is a file."; + + that.fs.readFile('/no-such-file', 'utf8', function(error, data) { + _error = error; + _result = data; + complete = true; + }); + + waitsFor(function() { + return complete; + }, 'test to complete', DEFAULT_TIMEOUT); + + runs(function() { + expect(_error).toBeDefined(); + expect(_result).not.toBeDefined(); + }); + }); + it('should write, read a utf8 file without specifying utf8 in writeFile', function() { var complete = false; var _error, _result;