-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for future fs.copyFile implementation and adjusted index.…
…js to run it.
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
var Filer = require('../../src'); | ||
var util = require('../lib/test-utils.js'); | ||
var expect = require('chai').expect; | ||
|
||
describe('fs.copyFile', function(){ | ||
beforeEach(function(done){ | ||
util.setup(function() { | ||
var fs = util.fs(); | ||
fs.writeFile('/srcfile', 'This is a src file.', function(error){ | ||
if(error) throw error; | ||
fs.writeFile('/destfile', 'This is a dest file.', function(error){ | ||
if(error) throw error; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
afterEach(util.cleanup); | ||
|
||
it('should be a function', function() { | ||
var fs = util.fs(); | ||
expect(fs.copyFile).to.be.a('function'); | ||
}); | ||
|
||
it('should return an error if the src path does not exist', function(done){ | ||
var fs = util.fs(); | ||
var src = null; | ||
var dest = 'dest.txt'; | ||
|
||
fs.copyFile(src, dest, function(error){ | ||
expect(error).to.exist; | ||
expect(error.code).to.equal('ENOENT'); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
it('should copy file successfully', function(done) { | ||
var fs = util.fs(); | ||
var src = "This is a src file."; | ||
|
||
fs.copyFile('/srcfile', '/destfile', function(error) { | ||
if(error) throw error; | ||
|
||
fs.readFile('/destfile', function(error, data){ | ||
expect(error).not.to.exist; | ||
expect(data).to.equal(src); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |