Rebase and rework test, skip() for now, see #594

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2018-12-02 10:14:26 -05:00 committed by David Humphrey
parent 97fb82769a
commit f5678ebe20
1 changed files with 30 additions and 28 deletions

View File

@ -73,33 +73,35 @@ describe('fs.watch', function() {
if(error) throw error; if(error) throw error;
}); });
}); });
});
it('should get a change event when a file hardlink is being watched and the original file is changed', function(done) { // Bug to deal with this is filed at https://github.com/filerjs/filer/issues/594
var fs = util.fs(); it.skip('should get a change event when a hardlink is watched and the original file is changed', function(done) {
var fs = util.fs();
fs.writeFile('/myfile', 'data', function(error) { fs.writeFile('/myfile', 'data', function(error) {
if(error) throw error;
fs.link('/myfile', '/hardlink', function(error) {
if(error) throw error; if(error) throw error;
fs.link('/myfile', '/hardlink', function(error) { var watcher = fs.watch('/hardlink', function(event, filename) {
if(error) throw error; expect(event).to.equal('change');
expect(filename).to.equal('/hardlink');
var watcher = fs.watch('/hardlink', function(event, filename) { watcher.close();
expect(event).to.equal('change');
expect(filename).to.equal('/hardlink');
watcher.close();
done();
});
fs.appendFile('/myfile', '...more data', function(error) { fs.readFile('/hardlink', 'utf8', function(error, data) {
if(error) throw error; if(error) throw error;
fs.readFile('/hardlink', 'utf8', function(error, data) { expect(data).to.equal('data...more data');
if(error) throw error; done();
expect(data).to.equal('data...more data')
});
}); });
}); });
fs.appendFile('/myfile', '...more data', function(error) {
if(error) throw error;
});
}); });
}); });
}); });
@ -109,19 +111,19 @@ describe('fs.watch', function() {
fs.writeFile('/myfile', 'data', function(error) { fs.writeFile('/myfile', 'data', function(error) {
if(error) throw error; if(error) throw error;
});
//Normaly A 'rename' event should be thrown, but filer doesn't support that event at this time. //Normaly A 'rename' event should be thrown, but filer doesn't support that event at this time.
//For now renaming a file will throw a change event. //For now renaming a file will throw a change event.
var watcher = fs.watch('/myfile', function(event, filename) { var watcher = fs.watch('/myfile', function(event, filename) {
expect(event).to.equal('change'); expect(event).to.equal('change');
expect(filename).to.equal('/myfile'); expect(filename).to.equal('/myfile');
watcher.close(); watcher.close();
done(); done();
}); });
fs.rename('/myfile', '/mynewfile', function(error) { fs.rename('/myfile', '/mynewfile', function(error) {
if(error) throw error; if(error) throw error;
});
}); });
}); });
}); });