Merge pull request #107 from humphd/issue106

[WIP] Failing test for issue 106
This commit is contained in:
David Humphrey 2014-02-11 14:27:56 -05:00
commit 1e5e06f18e
2 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,53 @@
define(["Filer"], function(Filer) {
describe('fs.writeFile truncation - issue 106', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new Filer.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should truncate an existing file', function() {
var fs = this.fs;
var filename = '/test';
var _complete = false;
var _size1, _size2;
fs.writeFile(filename, '1', function(err) {
if(err) throw err;
fs.stat(filename, function(err, stats) {
if(err) throw err;
_size1 = stats.size;
fs.writeFile(filename, '', function(err) {
if(err) throw err;
fs.stat(filename, function(err, stats) {
if(err) throw err;
_size2 = stats.size;
_complete = true;
});
});
});
});
waitsFor(function() {
return _complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_size1).toEqual(1);
expect(_size2).toEqual(0);
});
});
});
});

View File

@ -47,6 +47,7 @@ define([
"spec/node-js/simple/test-fs-null-bytes", "spec/node-js/simple/test-fs-null-bytes",
// Regressions, Bugs // Regressions, Bugs
"spec/regression/issue105" "spec/regression/issue105",
"spec/regression/issue106"
]); ]);