filer/tests/bugs/issue106.js

33 lines
808 B
JavaScript
Raw Permalink Normal View History

2014-05-23 20:53:50 +00:00
var Filer = require('../..');
var util = require('../lib/test-utils.js');
var expect = require('chai').expect;
2014-05-23 20:53:50 +00:00
describe('fs.writeFile truncation - issue 106', function() {
beforeEach(util.setup);
afterEach(util.cleanup);
2014-05-23 20:53:50 +00:00
it('should truncate an existing file', function(done) {
var fs = util.fs();
var filename = '/test';
2014-05-23 20:53:50 +00:00
fs.writeFile(filename, '1', function(err) {
if(err) throw err;
fs.stat(filename, function(err, stats) {
if(err) throw err;
2014-05-23 20:53:50 +00:00
expect(stats.size).to.equal(1);
2014-05-23 20:53:50 +00:00
fs.writeFile(filename, '', function(err) {
if(err) throw err;
2014-05-23 20:53:50 +00:00
fs.stat(filename, function(err, stats) {
if(err) throw err;
2014-05-23 20:53:50 +00:00
expect(stats.size).to.equal(0);
done();
});
});
});
});
});
});