From a0e6c70f97fe93126f68d9d286f8d01dd8825cc6 Mon Sep 17 00:00:00 2001 From: njadbe Date: Thu, 15 Dec 2011 15:36:58 -0800 Subject: [PATCH] Added tests for trying to read/write a directory using the read/writeFile APIs --- test/spec/LowLevelFileIO-test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/spec/LowLevelFileIO-test.js b/test/spec/LowLevelFileIO-test.js index 58991bc47..56b8a59c8 100644 --- a/test/spec/LowLevelFileIO-test.js +++ b/test/spec/LowLevelFileIO-test.js @@ -130,6 +130,12 @@ describe("LowLevelFileIO", function() { expect(err).toBe(brackets.fs.ERR_INVALID_PARAMS); }); }); + + it ("should return an error if trying to read a directory", function() { + brackets.fs.readFile(baseDir, "utf8", function(err, contents) { + expect(err).toBe(brackets.fs.ERR_CANT_READ); + }); + }) }); // describe("readFile") describe("writeFile", function() { @@ -157,5 +163,12 @@ describe("LowLevelFileIO", function() { expect(err).toBe(brackets.fs.ERR_INVALID_PARAMS); }); }); + + it ("should return an error if trying to write a directory", function() { + brackets.fs.writeFile(baseDir, contents, "utf8", function(err, contents) { + // Ideally we would get ERR_CANT_WRITE, but as long as we get some sort of error it's fine. + expect(err).toBeTruthy(); + }); + }) }); // describe("writeFile") });