From e7856453672bdfd4a9bb1e62956cfce23ee18dd1 Mon Sep 17 00:00:00 2001 From: Kyle Peyton Date: Tue, 15 Nov 2016 10:12:26 -0800 Subject: [PATCH] Adding copy sync test for src file without write perms --- lib/copy-sync/__tests__/copy-sync-file.test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/copy-sync/__tests__/copy-sync-file.test.js b/lib/copy-sync/__tests__/copy-sync-file.test.js index 34423592..7d0dd4cc 100644 --- a/lib/copy-sync/__tests__/copy-sync-file.test.js +++ b/lib/copy-sync/__tests__/copy-sync-file.test.js @@ -104,6 +104,23 @@ describe('+ copySync()', function () { }) }) + describe('> when the source file does not have write permissions', function () { + it('should be able to copy contents of file', function () { + var fileSrc = path.join(TEST_DIR, 'file.txt') + var fileDest = path.join(TEST_DIR, 'file-copy.txt') + var data = 'did it copy?' + + fs.writeFileSync(fileSrc, data, 'utf8') + fs.chmodSync(fileSrc, '0444') + + fs.copySync(fileSrc, fileDest) + + var data2 = fs.readFileSync(fileDest, 'utf8') + + assert.strictEqual(data, data2) + }) + }) + describe('> when clobber option is passed', function () { var src, dest var srcData = 'some src data'