Fix #633: fix test failure in coverage run

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2018-12-20 18:52:26 -05:00 committed by David Humphrey
parent 5cc21c72fb
commit bfe4385a83
5 changed files with 27 additions and 8 deletions

View File

@ -27,6 +27,10 @@
"semi": [ "semi": [
"error", "error",
"always" "always"
],
"eqeqeq": [
"error",
"always"
] ]
} }
} }

View File

@ -122,9 +122,9 @@ function FileSystem(options, callback) {
this.queueOrRun = function(operation) { this.queueOrRun = function(operation) {
var error; var error;
if(FS_READY == fs.readyState) { if(FS_READY === fs.readyState) {
operation.call(fs); operation.call(fs);
} else if(FS_ERROR == fs.readyState) { } else if(FS_ERROR === fs.readyState) {
error = new Errors.EFILESYSTEMERROR('unknown error'); error = new Errors.EFILESYSTEMERROR('unknown error');
} else { } else {
queue.push(operation); queue.push(operation);

View File

@ -1,6 +1,6 @@
function generateRandom(template) { function generateRandom(template) {
return template.replace(/[xy]/g, function(c) { return template.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
return v.toString(16); return v.toString(16);
}); });
} }

View File

@ -411,7 +411,7 @@ Shell.prototype.mkdirp = function(path, callback) {
var parent = Path.dirname(path); var parent = Path.dirname(path);
if(parent === '/') { if(parent === '/') {
fs.mkdir(path, function (err) { fs.mkdir(path, function (err) {
if (err && err.code != 'EEXIST') { if (err && err.code !== 'EEXIST') {
callback(err); callback(err);
return; return;
} }
@ -423,7 +423,7 @@ Shell.prototype.mkdirp = function(path, callback) {
_mkdirp(parent, function (err) { _mkdirp(parent, function (err) {
if (err) return callback(err); if (err) return callback(err);
fs.mkdir(path, function (err) { fs.mkdir(path, function (err) {
if (err && err.code != 'EEXIST') { if (err && err.code !== 'EEXIST') {
callback(err); callback(err);
return; return;
} }

View File

@ -15,8 +15,23 @@ describe('Filer', function() {
}); });
it('must honor the \'FORMAT\' flag', function(done) { it('must honor the \'FORMAT\' flag', function(done) {
var fs = new Filer.FileSystem({name: 'local-test'}); var name = 'local-test';
var fs2 = new Filer.FileSystem({name: 'local-test'}); // Because we need to use a bunch of Filer filesystems
// in this test, we can't use the usual test infrastructure
// to create/manage the fs instance. Pick the best one
// based on the testing environment (browser vs. node)
var providers = Filer.FileSystem.providers;
var Provider;
if(providers.IndexedDB.isSupported()) {
Provider = providers.IndexedDB;
} else if(providers.WebSQL.isSupported()) {
Provider = providers.WebSQL;
} else {
Provider = providers.Memory;
}
var fs = new Filer.FileSystem({name, provider: new Provider(name)});
var fs2 = new Filer.FileSystem({name, provider: new Provider(name)});
fs.mkdir('/test', function(err){ fs.mkdir('/test', function(err){
if(err) throw err; if(err) throw err;
@ -27,7 +42,7 @@ describe('Filer', function() {
expect(list).to.exist; expect(list).to.exist;
expect(list).to.have.length(1); expect(list).to.have.length(1);
fs2 = new Filer.FileSystem({name: 'local-test', flags:['FORMAT']}); fs2 = new Filer.FileSystem({name, provider: new Provider(name), flags:['FORMAT']});
fs2.readdir('/', function(err, list2) { fs2.readdir('/', function(err, list2) {
expect(err).to.not.exist; expect(err).to.not.exist;
expect(list2).to.exist; expect(list2).to.exist;