From 848cc7d3de336342a48b636a8d169ae9ff82aca0 Mon Sep 17 00:00:00 2001 From: Yuecheng Wu Date: Mon, 24 Sep 2018 14:35:41 -0400 Subject: [PATCH] Adding more tests for fs.copyFile Co-authored-by: David Humphrey --- tests/spec/fs.copyFile.spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/spec/fs.copyFile.spec.js b/tests/spec/fs.copyFile.spec.js index 940f2fb..a61a762 100644 --- a/tests/spec/fs.copyFile.spec.js +++ b/tests/spec/fs.copyFile.spec.js @@ -1,5 +1,6 @@ var util = require('../lib/test-utils.js'); var expect = require('chai').expect; +const { COPYFILE_EXCL } = require('../../src/constants').fsConstants; // Waiting on implementation to land https://github.com/filerjs/filer/issues/436 describe.skip('fs.copyFile', function() { @@ -45,4 +46,19 @@ describe.skip('fs.copyFile', function() { }); }); }); + + it('should return an error if flag=COPYFILE_EXCL and the destination file exists', function (done) { + var fs = util.fs(); + const destPath = '/destfile'; + + fs.writeFile(destPath, 'data', function(error) { + if(error) throw error; + + fs.copyFile(file.path, destPath, COPYFILE_EXCL, function(error) { + expect(error).to.exist; + expect(error.code).to.equal('ENOENT'); + done(); + }); + }); + }); });