-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #436 - Implement basic fs.copyFile tests without flags #481
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
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){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recommend isolating the creation of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, please move all these |
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is prone to being incorrect changed in the future, since it looks like you just forgot to initialize your variable. You need to document that you meant to do this. A few options:
|
||
var dest = 'dest.txt'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: consistency - here you declare There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, inline this. Also, paths in Filer must be absolute: |
||
|
||
fs.copyFile(src, dest, function(error){ | ||
expect(error).to.exist; | ||
expect(error.code).to.equal('ENOENT'); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
it('should copy file successfully', function(done) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This tests if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add some extra info to line 37 to indicate |
||
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(); | ||
}); | ||
}); | ||
}); | ||
|
||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: file should end with a blank line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add
.skip()
to this, since we know we can't pass these tests yet.https://mochajs.org/#inclusive-tests