From 1cbede711a2d6dcb02821aeb09529671b3f5dc5f Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Tue, 25 Mar 2014 19:19:42 -0400 Subject: [PATCH] Add test to confirm that fs.appendFile works when file is missing. --- tests/spec/fs.appendFile.spec.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/spec/fs.appendFile.spec.js b/tests/spec/fs.appendFile.spec.js index c0c66a1..c6585c4 100644 --- a/tests/spec/fs.appendFile.spec.js +++ b/tests/spec/fs.appendFile.spec.js @@ -110,6 +110,20 @@ define(["Filer", "util"], function(Filer, util) { }); }); }); - }); + it('should work when file does not exist, and create the file', function(done) { + var fs = util.fs(); + var contents = "This is a file."; + + fs.appendFile('/newfile', contents, { encoding: 'utf8' }, function(error) { + expect(error).not.to.exist; + + fs.readFile('/newfile', 'utf8', function(err, data) { + if(err) throw err; + expect(data).to.equal(contents); + done(); + }); + }); + }); + }); });