Add eslint --fix scripts, fix first round of lint errors
This commit is contained in:
parent
2ad0d0eb8b
commit
a900d8df6d
|
@ -17,7 +17,10 @@
|
||||||
"bugs": "https://github.com/filerjs/filer/issues",
|
"bugs": "https://github.com/filerjs/filer/issues",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"eslint": "npm run lint",
|
||||||
|
"eslint:fix": "npm run lint:fix",
|
||||||
"lint": "eslint src tests",
|
"lint": "eslint src tests",
|
||||||
|
"lint:fix": "eslint --fix src tests",
|
||||||
"test:manual": "parcel tests/index.html --out-dir tests/dist",
|
"test:manual": "parcel tests/index.html --out-dir tests/dist",
|
||||||
"pretest": "npm run lint",
|
"pretest": "npm run lint",
|
||||||
"test": "npm run travis",
|
"test": "npm run travis",
|
||||||
|
|
|
@ -7,7 +7,7 @@ function FilerBuffer (subject, encoding, nonZero) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Buffer(subject, encoding, nonZero);
|
return new Buffer(subject, encoding, nonZero);
|
||||||
};
|
}
|
||||||
|
|
||||||
// Inherit prototype from Buffer
|
// Inherit prototype from Buffer
|
||||||
FilerBuffer.prototype = Object.create(Buffer.prototype);
|
FilerBuffer.prototype = Object.create(Buffer.prototype);
|
||||||
|
|
|
@ -15,9 +15,9 @@ module.exports = {
|
||||||
IDB_RO: 'readonly',
|
IDB_RO: 'readonly',
|
||||||
IDB_RW: 'readwrite',
|
IDB_RW: 'readwrite',
|
||||||
|
|
||||||
WSQL_VERSION: "1",
|
WSQL_VERSION: '1',
|
||||||
WSQL_SIZE: 5 * 1024 * 1024,
|
WSQL_SIZE: 5 * 1024 * 1024,
|
||||||
WSQL_DESC: "FileSystem Storage",
|
WSQL_DESC: 'FileSystem Storage',
|
||||||
|
|
||||||
NODE_TYPE_FILE: 'FILE',
|
NODE_TYPE_FILE: 'FILE',
|
||||||
NODE_TYPE_DIRECTORY: 'DIRECTORY',
|
NODE_TYPE_DIRECTORY: 'DIRECTORY',
|
||||||
|
|
|
@ -1572,9 +1572,9 @@ function validate_flags(flags) {
|
||||||
function validate_file_options(options, enc, fileMode){
|
function validate_file_options(options, enc, fileMode){
|
||||||
if(!options) {
|
if(!options) {
|
||||||
options = { encoding: enc, flag: fileMode };
|
options = { encoding: enc, flag: fileMode };
|
||||||
} else if(typeof options === "function") {
|
} else if(typeof options === 'function') {
|
||||||
options = { encoding: enc, flag: fileMode };
|
options = { encoding: enc, flag: fileMode };
|
||||||
} else if(typeof options === "string") {
|
} else if(typeof options === 'string') {
|
||||||
options = { encoding: options, flag: fileMode };
|
options = { encoding: options, flag: fileMode };
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
|
@ -1832,10 +1832,10 @@ function writeFile(fs, context, path, data, options, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
data = data || '';
|
data = data || '';
|
||||||
if(typeof data === "number") {
|
if(typeof data === 'number') {
|
||||||
data = '' + data;
|
data = '' + data;
|
||||||
}
|
}
|
||||||
if(typeof data === "string" && options.encoding === 'utf8') {
|
if(typeof data === 'string' && options.encoding === 'utf8') {
|
||||||
data = Encoding.encode(data);
|
data = Encoding.encode(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1869,10 +1869,10 @@ function appendFile(fs, context, path, data, options, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
data = data || '';
|
data = data || '';
|
||||||
if(typeof data === "number") {
|
if(typeof data === 'number') {
|
||||||
data = '' + data;
|
data = '' + data;
|
||||||
}
|
}
|
||||||
if(typeof data === "string" && options.encoding === 'utf8') {
|
if(typeof data === 'string' && options.encoding === 'utf8') {
|
||||||
data = Encoding.encode(data);
|
data = Encoding.encode(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ var impl = require('./implementation.js');
|
||||||
|
|
||||||
// node.js supports a calling pattern that leaves off a callback.
|
// node.js supports a calling pattern that leaves off a callback.
|
||||||
function maybeCallback(callback) {
|
function maybeCallback(callback) {
|
||||||
if(typeof callback === "function") {
|
if(typeof callback === 'function') {
|
||||||
return callback;
|
return callback;
|
||||||
}
|
}
|
||||||
return function(err) {
|
return function(err) {
|
||||||
|
@ -104,7 +104,7 @@ function FileSystem(options, callback) {
|
||||||
// descriptor management functions
|
// descriptor management functions
|
||||||
var openFiles = {};
|
var openFiles = {};
|
||||||
var nextDescriptor = FIRST_DESCRIPTOR;
|
var nextDescriptor = FIRST_DESCRIPTOR;
|
||||||
Object.defineProperty(this, "openFiles", {
|
Object.defineProperty(this, 'openFiles', {
|
||||||
get: function() { return openFiles; }
|
get: function() { return openFiles; }
|
||||||
});
|
});
|
||||||
this.allocDescriptor = function(openFileDescription) {
|
this.allocDescriptor = function(openFileDescription) {
|
||||||
|
|
16
src/node.js
16
src/node.js
|
@ -14,15 +14,15 @@ var DEFAULT_DIR_PERMISSIONS = require('./constants.js').DEFAULT_DIR_PERMISSIONS;
|
||||||
|
|
||||||
function getMode(type, mode) {
|
function getMode(type, mode) {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case NODE_TYPE_DIRECTORY:
|
case NODE_TYPE_DIRECTORY:
|
||||||
return (mode || DEFAULT_DIR_PERMISSIONS) | S_IFDIR;
|
return (mode || DEFAULT_DIR_PERMISSIONS) | S_IFDIR;
|
||||||
case NODE_TYPE_SYMBOLIC_LINK:
|
case NODE_TYPE_SYMBOLIC_LINK:
|
||||||
return (mode || DEFAULT_FILE_PERMISSIONS) | S_IFLNK;
|
return (mode || DEFAULT_FILE_PERMISSIONS) | S_IFLNK;
|
||||||
/* jshint -W086 */
|
/* jshint -W086 */
|
||||||
case NODE_TYPE_FILE:
|
case NODE_TYPE_FILE:
|
||||||
// falls through
|
// falls through
|
||||||
default:
|
default:
|
||||||
return (mode || DEFAULT_FILE_PERMISSIONS) | S_IFREG;
|
return (mode || DEFAULT_FILE_PERMISSIONS) | S_IFREG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/path.js
10
src/path.js
|
@ -63,7 +63,7 @@ var splitPath = function(filename) {
|
||||||
// path.resolve([from ...], to)
|
// path.resolve([from ...], to)
|
||||||
function resolve() {
|
function resolve() {
|
||||||
var resolvedPath = '',
|
var resolvedPath = '',
|
||||||
resolvedAbsolute = false;
|
resolvedAbsolute = false;
|
||||||
|
|
||||||
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
||||||
// XXXfiler: we don't have process.cwd() so we use '/' as a fallback
|
// XXXfiler: we don't have process.cwd() so we use '/' as a fallback
|
||||||
|
@ -92,7 +92,7 @@ function resolve() {
|
||||||
// path.normalize(path)
|
// path.normalize(path)
|
||||||
function normalize(path) {
|
function normalize(path) {
|
||||||
var isAbsolute = path.charAt(0) === '/',
|
var isAbsolute = path.charAt(0) === '/',
|
||||||
trailingSlash = path.substr(-1) === '/';
|
trailingSlash = path.substr(-1) === '/';
|
||||||
|
|
||||||
// Normalize the path
|
// Normalize the path
|
||||||
path = normalizeArray(path.split('/').filter(function(p) {
|
path = normalizeArray(path.split('/').filter(function(p) {
|
||||||
|
@ -162,8 +162,8 @@ function relative(from, to) {
|
||||||
|
|
||||||
function dirname(path) {
|
function dirname(path) {
|
||||||
var result = splitPath(path),
|
var result = splitPath(path),
|
||||||
root = result[0],
|
root = result[0],
|
||||||
dir = result[1];
|
dir = result[1];
|
||||||
|
|
||||||
if (!root && !dir) {
|
if (!root && !dir) {
|
||||||
// No dirname whatsoever
|
// No dirname whatsoever
|
||||||
|
@ -185,7 +185,7 @@ function basename(path, ext) {
|
||||||
f = f.substr(0, f.length - ext.length);
|
f = f.substr(0, f.length - ext.length);
|
||||||
}
|
}
|
||||||
// XXXfiler: node.js just does `return f`
|
// XXXfiler: node.js just does `return f`
|
||||||
return f === "" ? "/" : f;
|
return f === '' ? '/' : f;
|
||||||
}
|
}
|
||||||
|
|
||||||
function extname(path) {
|
function extname(path) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function NotSupported() {
|
function NotSupported() {
|
||||||
throw "[Filer Error] Your browser doesn't support IndexedDB or WebSQL.";
|
throw '[Filer Error] Your browser doesn\'t support IndexedDB or WebSQL.';
|
||||||
}
|
}
|
||||||
NotSupported.isSupported = function() {
|
NotSupported.isSupported = function() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -24,7 +24,7 @@ function MemoryContext(db, readOnly) {
|
||||||
MemoryContext.prototype.clear = function(callback) {
|
MemoryContext.prototype.clear = function(callback) {
|
||||||
if(this.readOnly) {
|
if(this.readOnly) {
|
||||||
asyncCallback(function() {
|
asyncCallback(function() {
|
||||||
callback("[MemoryContext] Error: write operation on read only context");
|
callback('[MemoryContext] Error: write operation on read only context');
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ MemoryContext.prototype.putBuffer =
|
||||||
function(key, value, callback) {
|
function(key, value, callback) {
|
||||||
if(this.readOnly) {
|
if(this.readOnly) {
|
||||||
asyncCallback(function() {
|
asyncCallback(function() {
|
||||||
callback("[MemoryContext] Error: write operation on read only context");
|
callback('[MemoryContext] Error: write operation on read only context');
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ function(key, value, callback) {
|
||||||
MemoryContext.prototype.delete = function(key, callback) {
|
MemoryContext.prototype.delete = function(key, callback) {
|
||||||
if(this.readOnly) {
|
if(this.readOnly) {
|
||||||
asyncCallback(function() {
|
asyncCallback(function() {
|
||||||
callback("[MemoryContext] Error: write operation on read only context");
|
callback('[MemoryContext] Error: write operation on read only context');
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ WebSQLContext.prototype.clear = function(callback) {
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
this.getTransaction(function(transaction) {
|
this.getTransaction(function(transaction) {
|
||||||
transaction.executeSql("DELETE FROM " + FILE_STORE_NAME + ";",
|
transaction.executeSql('DELETE FROM ' + FILE_STORE_NAME + ';',
|
||||||
[], onSuccess, onError);
|
[], onSuccess, onError);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ function _get(getTransaction, key, callback) {
|
||||||
callback(error);
|
callback(error);
|
||||||
}
|
}
|
||||||
getTransaction(function(transaction) {
|
getTransaction(function(transaction) {
|
||||||
transaction.executeSql("SELECT data FROM " + FILE_STORE_NAME + " WHERE id = ? LIMIT 1;",
|
transaction.executeSql('SELECT data FROM ' + FILE_STORE_NAME + ' WHERE id = ? LIMIT 1;',
|
||||||
[key], onSuccess, onError);
|
[key], onSuccess, onError);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
WebSQLContext.prototype.getObject = function(key, callback) {
|
WebSQLContext.prototype.getObject = function(key, callback) {
|
||||||
|
@ -90,8 +90,8 @@ function _put(getTransaction, key, value, callback) {
|
||||||
callback(error);
|
callback(error);
|
||||||
}
|
}
|
||||||
getTransaction(function(transaction) {
|
getTransaction(function(transaction) {
|
||||||
transaction.executeSql("INSERT OR REPLACE INTO " + FILE_STORE_NAME + " (id, data) VALUES (?, ?);",
|
transaction.executeSql('INSERT OR REPLACE INTO ' + FILE_STORE_NAME + ' (id, data) VALUES (?, ?);',
|
||||||
[key, value], onSuccess, onError);
|
[key, value], onSuccess, onError);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
WebSQLContext.prototype.putObject = function(key, value, callback) {
|
WebSQLContext.prototype.putObject = function(key, value, callback) {
|
||||||
|
@ -111,8 +111,8 @@ WebSQLContext.prototype.delete = function(key, callback) {
|
||||||
callback(error);
|
callback(error);
|
||||||
}
|
}
|
||||||
this.getTransaction(function(transaction) {
|
this.getTransaction(function(transaction) {
|
||||||
transaction.executeSql("DELETE FROM " + FILE_STORE_NAME + " WHERE id = ?;",
|
transaction.executeSql('DELETE FROM ' + FILE_STORE_NAME + ' WHERE id = ?;',
|
||||||
[key], onSuccess, onError);
|
[key], onSuccess, onError);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ WebSQL.prototype.open = function(callback) {
|
||||||
|
|
||||||
var db = global.openDatabase(that.name, WSQL_VERSION, WSQL_DESC, WSQL_SIZE);
|
var db = global.openDatabase(that.name, WSQL_VERSION, WSQL_DESC, WSQL_SIZE);
|
||||||
if(!db) {
|
if(!db) {
|
||||||
callback("[WebSQL] Unable to open database.");
|
callback('[WebSQL] Unable to open database.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,12 +153,12 @@ WebSQL.prototype.open = function(callback) {
|
||||||
// Create the table and index we'll need to store the fs data.
|
// Create the table and index we'll need to store the fs data.
|
||||||
db.transaction(function(transaction) {
|
db.transaction(function(transaction) {
|
||||||
function createIndex(transaction) {
|
function createIndex(transaction) {
|
||||||
transaction.executeSql("CREATE INDEX IF NOT EXISTS idx_" + FILE_STORE_NAME + "_id" +
|
transaction.executeSql('CREATE INDEX IF NOT EXISTS idx_' + FILE_STORE_NAME + '_id' +
|
||||||
" on " + FILE_STORE_NAME + " (id);",
|
' on ' + FILE_STORE_NAME + ' (id);',
|
||||||
[], onSuccess, onError);
|
[], onSuccess, onError);
|
||||||
}
|
}
|
||||||
transaction.executeSql("CREATE TABLE IF NOT EXISTS " + FILE_STORE_NAME + " (id unique, data TEXT);",
|
transaction.executeSql('CREATE TABLE IF NOT EXISTS ' + FILE_STORE_NAME + ' (id unique, data TEXT);',
|
||||||
[], createIndex, onError);
|
[], createIndex, onError);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
WebSQL.prototype.getReadOnlyContext = function() {
|
WebSQL.prototype.getReadOnlyContext = function() {
|
||||||
|
|
|
@ -87,7 +87,7 @@ Shell.prototype.exec = function(path, args, callback) {
|
||||||
callback = callback || function(){};
|
callback = callback || function(){};
|
||||||
path = Path.resolve(sh.pwd(), path);
|
path = Path.resolve(sh.pwd(), path);
|
||||||
|
|
||||||
fs.readFile(path, "utf8", function(error, data) {
|
fs.readFile(path, 'utf8', function(error, data) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
return;
|
return;
|
||||||
|
@ -432,7 +432,7 @@ Shell.prototype.mkdirp = function(path, callback) {
|
||||||
* `find` returns a flat array of absolute paths for all matching/found
|
* `find` returns a flat array of absolute paths for all matching/found
|
||||||
* paths as the final argument to the callback.
|
* paths as the final argument to the callback.
|
||||||
*/
|
*/
|
||||||
Shell.prototype.find = function(path, options, callback) {
|
Shell.prototype.find = function(path, options, callback) {
|
||||||
var sh = this;
|
var sh = this;
|
||||||
var fs = sh.fs;
|
var fs = sh.fs;
|
||||||
if(typeof options === 'function') {
|
if(typeof options === 'function') {
|
||||||
|
|
|
@ -3,10 +3,10 @@ var expect = require('chai').expect;
|
||||||
|
|
||||||
describe('Path.resolve does not work, issue357', function() {
|
describe('Path.resolve does not work, issue357', function() {
|
||||||
it('Path.relative() should not crash', function() {
|
it('Path.relative() should not crash', function() {
|
||||||
expect(Path.relative("/mydir", "/mydir/file")).to.equal("file");
|
expect(Path.relative('/mydir', '/mydir/file')).to.equal('file');
|
||||||
|
|
||||||
// https://nodejs.org/api/path.html#path_path_relative_from_to
|
// https://nodejs.org/api/path.html#path_path_relative_from_to
|
||||||
expect(Path.relative("/data/orandea/test/aaa", "/data/orandea/impl/bbb")).to.equal("../../impl/bbb");
|
expect(Path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb')).to.equal('../../impl/bbb');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Path.resolve() should work as expectedh', function() {
|
it('Path.resolve() should work as expectedh', function() {
|
||||||
|
|
128
tests/index.js
128
tests/index.js
|
@ -4,77 +4,77 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Filer
|
// Filer
|
||||||
require("./spec/filer.spec");
|
require('./spec/filer.spec');
|
||||||
|
|
||||||
// Filer.FileSystem.*
|
// Filer.FileSystem.*
|
||||||
require("./spec/filer.filesystem.spec");
|
require('./spec/filer.filesystem.spec');
|
||||||
require("./spec/fs.spec");
|
require('./spec/fs.spec');
|
||||||
require("./spec/fs.stat.spec");
|
require('./spec/fs.stat.spec');
|
||||||
require("./spec/fs.lstat.spec");
|
require('./spec/fs.lstat.spec');
|
||||||
require("./spec/fs.exists.spec");
|
require('./spec/fs.exists.spec');
|
||||||
require("./spec/fs.mknod.spec");
|
require('./spec/fs.mknod.spec');
|
||||||
require("./spec/fs.mkdir.spec");
|
require('./spec/fs.mkdir.spec');
|
||||||
require("./spec/fs.readdir.spec");
|
require('./spec/fs.readdir.spec');
|
||||||
require("./spec/fs.rmdir.spec");
|
require('./spec/fs.rmdir.spec');
|
||||||
require("./spec/fs.open.spec");
|
require('./spec/fs.open.spec');
|
||||||
require("./spec/fs.write.spec");
|
require('./spec/fs.write.spec');
|
||||||
require("./spec/fs.writeFile-readFile.spec");
|
require('./spec/fs.writeFile-readFile.spec');
|
||||||
require("./spec/fs.appendFile.spec");
|
require('./spec/fs.appendFile.spec');
|
||||||
require("./spec/fs.read.spec");
|
require('./spec/fs.read.spec');
|
||||||
require("./spec/fs.close.spec");
|
require('./spec/fs.close.spec');
|
||||||
require("./spec/fs.link.spec");
|
require('./spec/fs.link.spec');
|
||||||
require("./spec/fs.unlink.spec");
|
require('./spec/fs.unlink.spec');
|
||||||
require("./spec/fs.rename.spec");
|
require('./spec/fs.rename.spec');
|
||||||
require("./spec/fs.lseek.spec");
|
require('./spec/fs.lseek.spec');
|
||||||
require("./spec/fs.symlink.spec");
|
require('./spec/fs.symlink.spec');
|
||||||
require("./spec/fs.readlink.spec");
|
require('./spec/fs.readlink.spec');
|
||||||
require("./spec/fs.truncate.spec");
|
require('./spec/fs.truncate.spec');
|
||||||
require("./spec/fs.utimes.spec");
|
require('./spec/fs.utimes.spec');
|
||||||
require("./spec/fs.xattr.spec");
|
require('./spec/fs.xattr.spec');
|
||||||
require("./spec/fs.stats.spec");
|
require('./spec/fs.stats.spec');
|
||||||
require("./spec/path-resolution.spec");
|
require('./spec/path-resolution.spec');
|
||||||
require("./spec/trailing-slashes.spec");
|
require('./spec/trailing-slashes.spec');
|
||||||
require("./spec/times.spec");
|
require('./spec/times.spec');
|
||||||
require("./spec/time-flags.spec");
|
require('./spec/time-flags.spec');
|
||||||
require("./spec/fs.watch.spec");
|
require('./spec/fs.watch.spec');
|
||||||
require("./spec/errors.spec");
|
require('./spec/errors.spec');
|
||||||
require("./spec/fs.shell.spec");
|
require('./spec/fs.shell.spec');
|
||||||
require("./spec/fs.chmod.spec");
|
require('./spec/fs.chmod.spec');
|
||||||
require("./spec/fs.chown.spec")
|
require('./spec/fs.chown.spec');
|
||||||
|
|
||||||
// Filer.FileSystem.providers.*
|
// Filer.FileSystem.providers.*
|
||||||
require("./spec/providers/providers.spec");
|
require('./spec/providers/providers.spec');
|
||||||
require("./spec/providers/providers.indexeddb.spec");
|
require('./spec/providers/providers.indexeddb.spec');
|
||||||
require("./spec/providers/providers.websql.spec");
|
require('./spec/providers/providers.websql.spec');
|
||||||
require("./spec/providers/providers.memory.spec");
|
require('./spec/providers/providers.memory.spec');
|
||||||
|
|
||||||
// Filer.FileSystemShell.*
|
// Filer.FileSystemShell.*
|
||||||
require("./spec/shell/cd.spec");
|
require('./spec/shell/cd.spec');
|
||||||
require("./spec/shell/touch.spec");
|
require('./spec/shell/touch.spec');
|
||||||
require("./spec/shell/exec.spec");
|
require('./spec/shell/exec.spec');
|
||||||
require("./spec/shell/cat.spec");
|
require('./spec/shell/cat.spec');
|
||||||
require("./spec/shell/ls.spec");
|
require('./spec/shell/ls.spec');
|
||||||
require("./spec/shell/rm.spec");
|
require('./spec/shell/rm.spec');
|
||||||
require("./spec/shell/env.spec");
|
require('./spec/shell/env.spec');
|
||||||
require("./spec/shell/mkdirp.spec");
|
require('./spec/shell/mkdirp.spec');
|
||||||
require("./spec/shell/find.spec");
|
require('./spec/shell/find.spec');
|
||||||
|
|
||||||
// Ported node.js tests (filenames match names in https://github.com/joyent/node/tree/master/test)
|
// Ported node.js tests (filenames match names in https://github.com/joyent/node/tree/master/test)
|
||||||
require("./spec/node-js/simple/test-fs-mkdir");
|
require('./spec/node-js/simple/test-fs-mkdir');
|
||||||
require("./spec/node-js/simple/test-fs-null-bytes");
|
require('./spec/node-js/simple/test-fs-null-bytes');
|
||||||
require("./spec/node-js/simple/test-fs-watch");
|
require('./spec/node-js/simple/test-fs-watch');
|
||||||
require("./spec/node-js/simple/test-fs-watch-recursive");
|
require('./spec/node-js/simple/test-fs-watch-recursive');
|
||||||
|
|
||||||
// Regressions, Bugs
|
// Regressions, Bugs
|
||||||
require("./bugs/issue105");
|
require('./bugs/issue105');
|
||||||
require("./bugs/issue106");
|
require('./bugs/issue106');
|
||||||
require("./bugs/issue239");
|
require('./bugs/issue239');
|
||||||
require("./bugs/issue249");
|
require('./bugs/issue249');
|
||||||
require("./bugs/ls-depth-bug");
|
require('./bugs/ls-depth-bug');
|
||||||
require("./bugs/issue247.js");
|
require('./bugs/issue247.js');
|
||||||
require("./bugs/issue254.js");
|
require('./bugs/issue254.js');
|
||||||
require("./bugs/issue258.js");
|
require('./bugs/issue258.js');
|
||||||
require("./bugs/issue267.js");
|
require('./bugs/issue267.js');
|
||||||
require("./bugs/issue270.js");
|
require('./bugs/issue270.js');
|
||||||
require("./bugs/rename-dir-trailing-slash.js");
|
require('./bugs/rename-dir-trailing-slash.js');
|
||||||
require("./bugs/issue357.js");
|
require('./bugs/issue357.js');
|
||||||
|
|
|
@ -40,7 +40,7 @@ function IndexedDBTestProvider(name) {
|
||||||
request.onsuccess = finished;
|
request.onsuccess = finished;
|
||||||
request.onerror = finished;
|
request.onerror = finished;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("Failed to delete test database", e);
|
console.log('Failed to delete test database', e);
|
||||||
finished();
|
finished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,20 +58,20 @@ function setup(callback) {
|
||||||
var name = uniqueName();
|
var name = uniqueName();
|
||||||
|
|
||||||
switch(providerType.toLowerCase()) {
|
switch(providerType.toLowerCase()) {
|
||||||
case 'indexeddb':
|
case 'indexeddb':
|
||||||
_provider = new IndexedDBTestProvider(name);
|
_provider = new IndexedDBTestProvider(name);
|
||||||
break;
|
break;
|
||||||
case 'websql':
|
case 'websql':
|
||||||
_provider = new WebSQLTestProvider(name);
|
_provider = new WebSQLTestProvider(name);
|
||||||
break;
|
break;
|
||||||
case 'memory':
|
case 'memory':
|
||||||
_provider = new MemoryTestProvider(name);
|
_provider = new MemoryTestProvider(name);
|
||||||
break;
|
break;
|
||||||
case 'default':
|
case 'default':
|
||||||
default:
|
default:
|
||||||
var BestProvider = findBestProvider();
|
var BestProvider = findBestProvider();
|
||||||
_provider = new BestProvider(name);
|
_provider = new BestProvider(name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow passing FS flags on query string
|
// Allow passing FS flags on query string
|
||||||
|
@ -95,14 +95,14 @@ function setup(callback) {
|
||||||
|
|
||||||
function fs() {
|
function fs() {
|
||||||
if(!_fs) {
|
if(!_fs) {
|
||||||
throw "TestUtil: call setup() before fs()";
|
throw 'TestUtil: call setup() before fs()';
|
||||||
}
|
}
|
||||||
return _fs;
|
return _fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function provider() {
|
function provider() {
|
||||||
if(!_provider) {
|
if(!_provider) {
|
||||||
throw "TestUtil: call setup() before provider()";
|
throw 'TestUtil: call setup() before provider()';
|
||||||
}
|
}
|
||||||
return _provider;
|
return _provider;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
var Filer = require('../../src');
|
var Filer = require('../../src');
|
||||||
var expect = require('chai').expect;
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
describe("Filer.Errors", function() {
|
describe('Filer.Errors', function() {
|
||||||
it("has expected errors", function() {
|
it('has expected errors', function() {
|
||||||
expect(Filer.Errors).to.exist;
|
expect(Filer.Errors).to.exist;
|
||||||
|
|
||||||
// By ctor -- if you add some to src/errors.js, also add here
|
// By ctor -- if you add some to src/errors.js, also add here
|
||||||
|
@ -165,12 +165,12 @@ describe("Filer.Errors", function() {
|
||||||
|
|
||||||
it('should not include path in toString() when not provided', function() {
|
it('should not include path in toString() when not provided', function() {
|
||||||
var err = new Filer.Errors.ENOENT('This is the message');
|
var err = new Filer.Errors.ENOENT('This is the message');
|
||||||
expect(err.toString()).to.equal("ENOENT: This is the message");
|
expect(err.toString()).to.equal('ENOENT: This is the message');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should include path in toString() when provided', function() {
|
it('should include path in toString() when provided', function() {
|
||||||
var err = new Filer.Errors.ENOENT(null, '/this/is/the/path');
|
var err = new Filer.Errors.ENOENT(null, '/this/is/the/path');
|
||||||
expect(err.toString()).to.equal("ENOENT: no such file or directory, '/this/is/the/path'");
|
expect(err.toString()).to.equal('ENOENT: no such file or directory, \'/this/is/the/path\'');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should include message and path info when provided', function() {
|
it('should include message and path info when provided', function() {
|
||||||
|
|
|
@ -2,7 +2,7 @@ var Filer = require('../../src');
|
||||||
var util = require('../lib/test-utils.js');
|
var util = require('../lib/test-utils.js');
|
||||||
var expect = require('chai').expect;
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
describe("Filer.FileSystem", function() {
|
describe('Filer.FileSystem', function() {
|
||||||
beforeEach(util.setup);
|
beforeEach(util.setup);
|
||||||
afterEach(util.cleanup);
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
var Filer = require('../../src');
|
var Filer = require('../../src');
|
||||||
var expect = require('chai').expect;
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
describe("Filer", function() {
|
describe('Filer', function() {
|
||||||
it("is defined", function() {
|
it('is defined', function() {
|
||||||
expect(typeof Filer).not.to.equal(undefined);
|
expect(typeof Filer).not.to.equal(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has FileSystem constructor", function() {
|
it('has FileSystem constructor', function() {
|
||||||
expect(typeof Filer.FileSystem).to.equal('function');
|
expect(typeof Filer.FileSystem).to.equal('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has Shell constructor", function() {
|
it('has Shell constructor', function() {
|
||||||
expect(typeof Filer.Shell).to.equal('function');
|
expect(typeof Filer.Shell).to.equal('function');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe('fs.appendFile', function() {
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
util.setup(function() {
|
util.setup(function() {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
fs.writeFile('/myfile', "This is a file.", { encoding: 'utf8' }, function(error) {
|
fs.writeFile('/myfile', 'This is a file.', { encoding: 'utf8' }, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -20,8 +20,8 @@ describe('fs.appendFile', function() {
|
||||||
|
|
||||||
it('should append a utf8 file without specifying utf8 in appendFile', function(done) {
|
it('should append a utf8 file without specifying utf8 in appendFile', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
var more = " Appended.";
|
var more = ' Appended.';
|
||||||
|
|
||||||
fs.appendFile('/myfile', more, function(error) {
|
fs.appendFile('/myfile', more, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
@ -36,8 +36,8 @@ describe('fs.appendFile', function() {
|
||||||
|
|
||||||
it('should append a utf8 file with "utf8" option to appendFile', function(done) {
|
it('should append a utf8 file with "utf8" option to appendFile', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
var more = " Appended.";
|
var more = ' Appended.';
|
||||||
|
|
||||||
fs.appendFile('/myfile', more, 'utf8', function(error) {
|
fs.appendFile('/myfile', more, 'utf8', function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
@ -52,8 +52,8 @@ describe('fs.appendFile', function() {
|
||||||
|
|
||||||
it('should append a utf8 file with {encoding: "utf8"} option to appendFile', function(done) {
|
it('should append a utf8 file with {encoding: "utf8"} option to appendFile', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
var more = " Appended.";
|
var more = ' Appended.';
|
||||||
|
|
||||||
fs.appendFile('/myfile', more, { encoding: 'utf8' }, function(error) {
|
fs.appendFile('/myfile', more, { encoding: 'utf8' }, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
@ -70,12 +70,12 @@ describe('fs.appendFile', function() {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
|
|
||||||
// String and utf8 binary encoded versions of the same thing:
|
// String and utf8 binary encoded versions of the same thing:
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
var binary = new Buffer([84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 102, 105, 108, 101, 46]);
|
var binary = new Buffer([84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 102, 105, 108, 101, 46]);
|
||||||
var more = " Appended.";
|
var more = ' Appended.';
|
||||||
var binary2 = new Buffer([32, 65, 112, 112, 101, 110, 100, 101, 100, 46]);
|
var binary2 = new Buffer([32, 65, 112, 112, 101, 110, 100, 101, 100, 46]);
|
||||||
var binary3 = new Buffer([84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 102, 105, 108, 101, 46,
|
var binary3 = new Buffer([84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 102, 105, 108, 101, 46,
|
||||||
32, 65, 112, 112, 101, 110, 100, 101, 100, 46]);
|
32, 65, 112, 112, 101, 110, 100, 101, 100, 46]);
|
||||||
|
|
||||||
fs.writeFile('/mybinaryfile', binary, function(error) {
|
fs.writeFile('/mybinaryfile', binary, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
@ -94,8 +94,8 @@ describe('fs.appendFile', function() {
|
||||||
|
|
||||||
it('should follow symbolic links', function(done) {
|
it('should follow symbolic links', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
var more = " Appended.";
|
var more = ' Appended.';
|
||||||
|
|
||||||
fs.symlink('/myfile', '/myFileLink', function (error) {
|
fs.symlink('/myfile', '/myFileLink', function (error) {
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
@ -114,7 +114,7 @@ describe('fs.appendFile', function() {
|
||||||
|
|
||||||
it('should work when file does not exist, and create the file', function(done) {
|
it('should work when file does not exist, and create the file', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
|
|
||||||
fs.appendFile('/newfile', contents, { encoding: 'utf8' }, function(error) {
|
fs.appendFile('/newfile', contents, { encoding: 'utf8' }, function(error) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
|
|
|
@ -43,7 +43,7 @@ describe('fs.link', function() {
|
||||||
|
|
||||||
it('should create hard link to identical data node', function(done) {
|
it('should create hard link to identical data node', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "Hello World!";
|
var contents = 'Hello World!';
|
||||||
|
|
||||||
fs.writeFile('/file', contents, function(err) {
|
fs.writeFile('/file', contents, function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe('fs.lstat', function() {
|
||||||
|
|
||||||
fs.lstat('/tmp', function(error, result) {
|
fs.lstat('/tmp', function(error, result) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('fs.mkdir', function() {
|
||||||
|
|
||||||
fs.mkdir('/tmp/mydir', function(error) {
|
fs.mkdir('/tmp/mydir', function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ describe('fs.mkdir', function() {
|
||||||
|
|
||||||
fs.mkdir('/', function(error) {
|
fs.mkdir('/', function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EEXIST");
|
expect(error.code).to.equal('EEXIST');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe('fs.open', function() {
|
||||||
|
|
||||||
fs.open('/tmp/myfile', 'w+', function(error, result) {
|
fs.open('/tmp/myfile', 'w+', function(error, result) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -27,7 +27,7 @@ describe('fs.open', function() {
|
||||||
|
|
||||||
fs.open('/myfile', 'r+', function(error, result) {
|
fs.open('/myfile', 'r+', function(error, result) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -40,7 +40,7 @@ describe('fs.open', function() {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
fs.open('/tmp', 'w', function(error, result) {
|
fs.open('/tmp', 'w', function(error, result) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EISDIR");
|
expect(error.code).to.equal('EISDIR');
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -54,7 +54,7 @@ describe('fs.open', function() {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
fs.open('/tmp', 'a', function(error, result) {
|
fs.open('/tmp', 'a', function(error, result) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EISDIR");
|
expect(error.code).to.equal('EISDIR');
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('fs.readdir', function() {
|
||||||
|
|
||||||
fs.readdir('/tmp/mydir', function(error, files) {
|
fs.readdir('/tmp/mydir', function(error, files) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
expect(files).not.to.exist;
|
expect(files).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('fs.readlink', function() {
|
||||||
|
|
||||||
fs.readlink('/tmp/mydir', function(error) {
|
fs.readlink('/tmp/mydir', function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ describe('fs.readlink', function() {
|
||||||
|
|
||||||
fs.readlink('/', function(error) {
|
fs.readlink('/', function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('fs.rmdir', function() {
|
||||||
|
|
||||||
fs.rmdir('/tmp/mydir', function(error) {
|
fs.rmdir('/tmp/mydir', function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ describe('fs.rmdir', function() {
|
||||||
|
|
||||||
fs.rmdir('/', function(error) {
|
fs.rmdir('/', function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EBUSY");
|
expect(error.code).to.equal('EBUSY');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -39,7 +39,7 @@ describe('fs.rmdir', function() {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
fs.rmdir('/', function(error) {
|
fs.rmdir('/', function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EBUSY");
|
expect(error.code).to.equal('EBUSY');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -57,7 +57,7 @@ describe('fs.rmdir', function() {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
fs.rmdir('/tmp/myfile', function(error) {
|
fs.rmdir('/tmp/myfile', function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOTDIR");
|
expect(error.code).to.equal('ENOTDIR');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -74,7 +74,7 @@ describe('fs.rmdir', function() {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
fs.rmdir('/tmp/myfile', function (error) {
|
fs.rmdir('/tmp/myfile', function (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOTDIR");
|
expect(error.code).to.equal('ENOTDIR');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,11 +2,11 @@ var Filer = require('../../src');
|
||||||
var util = require('../lib/test-utils.js');
|
var util = require('../lib/test-utils.js');
|
||||||
var expect = require('chai').expect;
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
describe("fs.Shell", function() {
|
describe('fs.Shell', function() {
|
||||||
beforeEach(util.setup);
|
beforeEach(util.setup);
|
||||||
afterEach(util.cleanup);
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
it("is a function", function(done) {
|
it('is a function', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
expect(typeof fs.Shell).to.equal('function');
|
expect(typeof fs.Shell).to.equal('function');
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ describe("fs.Shell", function() {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var sh = new fs.Shell();
|
var sh = new fs.Shell();
|
||||||
|
|
||||||
Filer.Shell.prototype.test = "foo";
|
Filer.Shell.prototype.test = 'foo';
|
||||||
|
|
||||||
expect(sh.test).to.equal("foo");
|
expect(sh.test).to.equal('foo');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,11 +2,11 @@ var Filer = require('../../src');
|
||||||
var util = require('../lib/test-utils.js');
|
var util = require('../lib/test-utils.js');
|
||||||
var expect = require('chai').expect;
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
describe("fs", function() {
|
describe('fs', function() {
|
||||||
beforeEach(util.setup);
|
beforeEach(util.setup);
|
||||||
afterEach(util.cleanup);
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
it("is an object", function() {
|
it('is an object', function() {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
expect(typeof fs).to.equal('object');
|
expect(typeof fs).to.equal('object');
|
||||||
expect(fs).to.be.an.instanceof(Filer.FileSystem);
|
expect(fs).to.be.an.instanceof(Filer.FileSystem);
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('fs.stat', function() {
|
||||||
|
|
||||||
fs.stat('/tmp', function(error, result) {
|
fs.stat('/tmp', function(error, result) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -274,7 +274,7 @@ describe('fs.stats', function() {
|
||||||
expect(stats.name).to.equal(Path.basename(filepath));
|
expect(stats.name).to.equal(Path.basename(filepath));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should correct return name for an fd', function(done) {
|
it('should correct return name for an fd', function(done) {
|
||||||
|
@ -290,7 +290,7 @@ describe('fs.stats', function() {
|
||||||
expect(stats.name).to.equal(Path.basename(filepath));
|
expect(stats.name).to.equal(Path.basename(filepath));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('fs.symlink', function() {
|
||||||
|
|
||||||
fs.symlink('/', '/tmp/mydir', function(error) {
|
fs.symlink('/', '/tmp/mydir', function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ describe('fs.symlink', function() {
|
||||||
|
|
||||||
fs.symlink('/tmp', '/', function(error) {
|
fs.symlink('/tmp', '/', function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EEXIST");
|
expect(error.code).to.equal('EEXIST');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,14 +12,14 @@ describe('fs.truncate', function() {
|
||||||
|
|
||||||
it('should error when length is negative', function(done) {
|
it('should error when length is negative', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
|
|
||||||
fs.writeFile('/myfile', contents, function(error) {
|
fs.writeFile('/myfile', contents, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
fs.truncate('/myfile', -1, function(error) {
|
fs.truncate('/myfile', -1, function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EINVAL");
|
expect(error.code).to.equal('EINVAL');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -30,7 +30,7 @@ describe('fs.truncate', function() {
|
||||||
|
|
||||||
fs.truncate('/', 0, function(error) {
|
fs.truncate('/', 0, function(error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EISDIR");
|
expect(error.code).to.equal('EISDIR');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -126,7 +126,7 @@ describe('fs.utimes', function() {
|
||||||
fs.fstat(ofd, function (error, stat) {
|
fs.fstat(ofd, function (error, stat) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
expect(stat.mtime).to.equal(mtime);
|
expect(stat.mtime).to.equal(mtime);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,11 +13,11 @@ describe('fs.writeFile, fs.readFile', function() {
|
||||||
|
|
||||||
it('should error when path is wrong to readFile', function(done) {
|
it('should error when path is wrong to readFile', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
|
|
||||||
fs.readFile('/no-such-file', 'utf8', function(error, data) {
|
fs.readFile('/no-such-file', 'utf8', function(error, data) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
expect(data).not.to.exist;
|
expect(data).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ describe('fs.writeFile, fs.readFile', function() {
|
||||||
|
|
||||||
it('should write, read a utf8 file without specifying utf8 in writeFile', function(done) {
|
it('should write, read a utf8 file without specifying utf8 in writeFile', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
|
|
||||||
fs.writeFile('/myfile', contents, function(error) {
|
fs.writeFile('/myfile', contents, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
@ -39,7 +39,7 @@ describe('fs.writeFile, fs.readFile', function() {
|
||||||
|
|
||||||
it('should write, read a utf8 file with "utf8" option to writeFile', function(done) {
|
it('should write, read a utf8 file with "utf8" option to writeFile', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
|
|
||||||
fs.writeFile('/myfile', contents, 'utf8', function(error) {
|
fs.writeFile('/myfile', contents, 'utf8', function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
@ -53,7 +53,7 @@ describe('fs.writeFile, fs.readFile', function() {
|
||||||
|
|
||||||
it('should write, read a utf8 file with {encoding: "utf8"} option to writeFile', function(done) {
|
it('should write, read a utf8 file with {encoding: "utf8"} option to writeFile', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
|
|
||||||
fs.writeFile('/myfile', contents, { encoding: 'utf8' }, function(error) {
|
fs.writeFile('/myfile', contents, { encoding: 'utf8' }, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
@ -68,7 +68,7 @@ describe('fs.writeFile, fs.readFile', function() {
|
||||||
it('should write, read a binary file', function(done) {
|
it('should write, read a binary file', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
// String and utf8 binary encoded versions of the same thing:
|
// String and utf8 binary encoded versions of the same thing:
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
var binary = new Buffer([84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 102, 105, 108, 101, 46]);
|
var binary = new Buffer([84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 102, 105, 108, 101, 46]);
|
||||||
|
|
||||||
fs.writeFile('/myfile', binary, function(error) {
|
fs.writeFile('/myfile', binary, function(error) {
|
||||||
|
@ -83,7 +83,7 @@ describe('fs.writeFile, fs.readFile', function() {
|
||||||
|
|
||||||
it('should follow symbolic links', function(done) {
|
it('should follow symbolic links', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var contents = "This is a file.";
|
var contents = 'This is a file.';
|
||||||
|
|
||||||
fs.writeFile('/myfile', '', { encoding: 'utf8' }, function(error) {
|
fs.writeFile('/myfile', '', { encoding: 'utf8' }, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
|
@ -288,7 +288,7 @@ describe('fs.xattr', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
var util = require('../../../lib/test-utils.js');
|
var util = require('../../../lib/test-utils.js');
|
||||||
var expect = require('chai').expect;
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/test-fs-mkdir.js", function() {
|
describe('node.js tests: https://github.com/joyent/node/blob/master/test/simple/test-fs-mkdir.js', function() {
|
||||||
beforeEach(util.setup);
|
beforeEach(util.setup);
|
||||||
afterEach(util.cleanup);
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
var util = require('../../../lib/test-utils.js');
|
var util = require('../../../lib/test-utils.js');
|
||||||
var expect = require('chai').expect;
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/test-fs-null-bytes.js", function() {
|
describe('node.js tests: https://github.com/joyent/node/blob/master/test/simple/test-fs-null-bytes.js', function() {
|
||||||
beforeEach(util.setup);
|
beforeEach(util.setup);
|
||||||
afterEach(util.cleanup);
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/
|
||||||
var checks = [];
|
var checks = [];
|
||||||
var fnCount = 0;
|
var fnCount = 0;
|
||||||
var fnTotal = 16;
|
var fnTotal = 16;
|
||||||
var expected = "Path must be a string without null bytes.";
|
var expected = 'Path must be a string without null bytes.';
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
|
|
||||||
// Make sure function fails with null path error in callback.
|
// Make sure function fails with null path error in callback.
|
||||||
|
@ -47,8 +47,8 @@ describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/
|
||||||
check(fs.appendFile, '/foo\u0000bar');
|
check(fs.appendFile, '/foo\u0000bar');
|
||||||
check(fs.truncate, '/foo\u0000bar');
|
check(fs.truncate, '/foo\u0000bar');
|
||||||
check(fs.utimes, '/foo\u0000bar', 0, 0);
|
check(fs.utimes, '/foo\u0000bar', 0, 0);
|
||||||
// Not implemented
|
// Not implemented
|
||||||
// check(fs.realpath, '/foo\u0000bar');
|
// check(fs.realpath, '/foo\u0000bar');
|
||||||
check(fs.chmod, '/foo\u0000bar', '0644');
|
check(fs.chmod, '/foo\u0000bar', '0644');
|
||||||
check(fs.chown, '/foo\u0000bar', 12, 34);
|
check(fs.chown, '/foo\u0000bar', 12, 34);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ var expect = require('chai').expect;
|
||||||
* fd vs. path) for events, or gives only a portion thereof (e.g., basname),
|
* fd vs. path) for events, or gives only a portion thereof (e.g., basname),
|
||||||
* we give full, abs paths always.
|
* we give full, abs paths always.
|
||||||
*/
|
*/
|
||||||
describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/test-fs-watch-recursive.js", function() {
|
describe('node.js tests: https://github.com/joyent/node/blob/master/test/simple/test-fs-watch-recursive.js', function() {
|
||||||
beforeEach(util.setup);
|
beforeEach(util.setup);
|
||||||
afterEach(util.cleanup);
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ var expect = require('chai').expect;
|
||||||
var filenameOne = '/watch.txt';
|
var filenameOne = '/watch.txt';
|
||||||
var filenameTwo = '/hasOwnProperty';
|
var filenameTwo = '/hasOwnProperty';
|
||||||
|
|
||||||
describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/test-fs-watch.js", function() {
|
describe('node.js tests: https://github.com/joyent/node/blob/master/test/simple/test-fs-watch.js', function() {
|
||||||
beforeEach(util.setup);
|
beforeEach(util.setup);
|
||||||
afterEach(util.cleanup);
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
var watcher = fs.watch('/tmp', function(event, filename) {
|
var watcher = fs.watch('/tmp', function(event, filename) {
|
||||||
// TODO: node thinks this should be 'rename', need to add rename along with change.
|
// TODO: node thinks this should be 'rename', need to add rename along with change.
|
||||||
expect(event).to.equal('change');
|
expect(event).to.equal('change');
|
||||||
expect(filename).to.equal('/tmp');
|
expect(filename).to.equal('/tmp');
|
||||||
watcher.close();
|
watcher.close();
|
||||||
|
|
|
@ -121,7 +121,7 @@ describe('path resolution', function() {
|
||||||
|
|
||||||
fs.stat('/myfilelink1', function(error, result) {
|
fs.stat('/myfilelink1', function(error, result) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOENT");
|
expect(error.code).to.equal('ENOENT');
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -212,7 +212,7 @@ describe('path resolution', function() {
|
||||||
|
|
||||||
fs.stat('/mynotdirlink/myfile', function(error, result) {
|
fs.stat('/mynotdirlink/myfile', function(error, result) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("ENOTDIR");
|
expect(error.code).to.equal('ENOTDIR');
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,11 +8,11 @@ var expect = require('chai').expect;
|
||||||
*/
|
*/
|
||||||
module.exports = function createProviderTestsFor(providerName, testProvider) {
|
module.exports = function createProviderTestsFor(providerName, testProvider) {
|
||||||
if(!testProvider.isSupported()) {
|
if(!testProvider.isSupported()) {
|
||||||
console.log("Skipping provider tests for `" + providerName +"'--not supported in current environment.");
|
console.log('Skipping provider tests for `' + providerName +'\'--not supported in current environment.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("Filer Provider Tests for " + providerName, function() {
|
describe('Filer Provider Tests for ' + providerName, function() {
|
||||||
var _provider;
|
var _provider;
|
||||||
var provider;
|
var provider;
|
||||||
|
|
||||||
|
@ -29,27 +29,27 @@ module.exports = function createProviderTestsFor(providerName, testProvider) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("has open, getReadOnlyContext, and getReadWriteContext instance methods", function() {
|
it('has open, getReadOnlyContext, and getReadWriteContext instance methods', function() {
|
||||||
expect(provider.open).to.be.a('function');
|
expect(provider.open).to.be.a('function');
|
||||||
expect(provider.getReadOnlyContext).to.be.a('function');
|
expect(provider.getReadOnlyContext).to.be.a('function');
|
||||||
expect(provider.getReadWriteContext).to.be.a('function');
|
expect(provider.getReadWriteContext).to.be.a('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should open a new provider database", function(done) {
|
it('should open a new provider database', function(done) {
|
||||||
provider.open(function(error) {
|
provider.open(function(error) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should allow putObject() and getObject()", function(done) {
|
it('should allow putObject() and getObject()', function(done) {
|
||||||
provider.open(function(error, firstAccess) {
|
provider.open(function(error, firstAccess) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
var context = provider.getReadWriteContext();
|
var context = provider.getReadWriteContext();
|
||||||
// Simple JS Object
|
// Simple JS Object
|
||||||
var value = {
|
var value = {
|
||||||
a: "a",
|
a: 'a',
|
||||||
b: 1,
|
b: 1,
|
||||||
c: true,
|
c: true,
|
||||||
d: [1,2,3],
|
d: [1,2,3],
|
||||||
|
@ -57,10 +57,10 @@ module.exports = function createProviderTestsFor(providerName, testProvider) {
|
||||||
e1: ['a', 'b', 'c']
|
e1: ['a', 'b', 'c']
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
context.putObject("key", value, function(error) {
|
context.putObject('key', value, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
context.getObject("key", function(error, result) {
|
context.getObject('key', function(error, result) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
expect(result).to.be.an('object');
|
expect(result).to.be.an('object');
|
||||||
expect(result).to.deep.equal(value);
|
expect(result).to.deep.equal(value);
|
||||||
|
@ -70,17 +70,17 @@ module.exports = function createProviderTestsFor(providerName, testProvider) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should allow putBuffer() and getBuffer()", function(done) {
|
it('should allow putBuffer() and getBuffer()', function(done) {
|
||||||
provider.open(function(error, firstAccess) {
|
provider.open(function(error, firstAccess) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
var context = provider.getReadWriteContext();
|
var context = provider.getReadWriteContext();
|
||||||
// Filer Buffer
|
// Filer Buffer
|
||||||
var buf = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
var buf = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
||||||
context.putBuffer("key", buf, function(error) {
|
context.putBuffer('key', buf, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
context.getBuffer("key", function(error, result) {
|
context.getBuffer('key', function(error, result) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
expect(Buffer.isBuffer(result)).to.be.true;
|
expect(Buffer.isBuffer(result)).to.be.true;
|
||||||
expect(result).to.deep.equal(buf);
|
expect(result).to.deep.equal(buf);
|
||||||
|
@ -90,17 +90,17 @@ module.exports = function createProviderTestsFor(providerName, testProvider) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should allow zero-length Buffers with putBuffer() and getBuffer()", function(done) {
|
it('should allow zero-length Buffers with putBuffer() and getBuffer()', function(done) {
|
||||||
provider.open(function(error, firstAccess) {
|
provider.open(function(error, firstAccess) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
var context = provider.getReadWriteContext();
|
var context = provider.getReadWriteContext();
|
||||||
// Zero-length Filer Buffer
|
// Zero-length Filer Buffer
|
||||||
var buf = new Buffer(new ArrayBuffer(0));
|
var buf = new Buffer(new ArrayBuffer(0));
|
||||||
context.putBuffer("key", buf, function(error) {
|
context.putBuffer('key', buf, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
context.getBuffer("key", function(error, result) {
|
context.getBuffer('key', function(error, result) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
expect(Buffer.isBuffer(result)).to.be.true;
|
expect(Buffer.isBuffer(result)).to.be.true;
|
||||||
expect(result).to.deep.equal(buf);
|
expect(result).to.deep.equal(buf);
|
||||||
|
@ -110,19 +110,19 @@ module.exports = function createProviderTestsFor(providerName, testProvider) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should allow delete()", function(done) {
|
it('should allow delete()', function(done) {
|
||||||
var provider = _provider.provider;
|
var provider = _provider.provider;
|
||||||
provider.open(function(error, firstAccess) {
|
provider.open(function(error, firstAccess) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
var context = provider.getReadWriteContext();
|
var context = provider.getReadWriteContext();
|
||||||
context.putObject("key", "value", function(error) {
|
context.putObject('key', 'value', function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
context.delete("key", function(error) {
|
context.delete('key', function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
context.getObject("key", function(error, result) {
|
context.getObject('key', function(error, result) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
done();
|
done();
|
||||||
|
@ -132,25 +132,25 @@ module.exports = function createProviderTestsFor(providerName, testProvider) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should allow clear()", function(done) {
|
it('should allow clear()', function(done) {
|
||||||
provider.open(function(error, firstAccess) {
|
provider.open(function(error, firstAccess) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
var context = provider.getReadWriteContext();
|
var context = provider.getReadWriteContext();
|
||||||
context.putObject("key1", "value1", function(error) {
|
context.putObject('key1', 'value1', function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
context.putObject("key2", "value2", function(error) {
|
context.putObject('key2', 'value2', function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
context.clear(function(err) {
|
context.clear(function(err) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
||||||
context.getObject("key1", function(error, result) {
|
context.getObject('key1', function(error, result) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
|
|
||||||
context.getObject("key2", function(error, result) {
|
context.getObject('key2', function(error, result) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
done();
|
done();
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
var Filer = require('../../../src');
|
var Filer = require('../../../src');
|
||||||
var expect = require('chai').expect;
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
describe("Filer.FileSystem.providers", function() {
|
describe('Filer.FileSystem.providers', function() {
|
||||||
it("is defined", function() {
|
it('is defined', function() {
|
||||||
expect(Filer.FileSystem.providers).to.exist;
|
expect(Filer.FileSystem.providers).to.exist;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has IndexedDB constructor", function() {
|
it('has IndexedDB constructor', function() {
|
||||||
expect(Filer.FileSystem.providers.IndexedDB).to.be.a('function');
|
expect(Filer.FileSystem.providers.IndexedDB).to.be.a('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has WebSQL constructor", function() {
|
it('has WebSQL constructor', function() {
|
||||||
expect(Filer.FileSystem.providers.WebSQL).to.be.a('function');
|
expect(Filer.FileSystem.providers.WebSQL).to.be.a('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has Memory constructor", function() {
|
it('has Memory constructor', function() {
|
||||||
expect(Filer.FileSystem.providers.Memory).to.be.a('function');
|
expect(Filer.FileSystem.providers.Memory).to.be.a('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a Default constructor", function() {
|
it('has a Default constructor', function() {
|
||||||
expect(Filer.FileSystem.providers.Default).to.be.a('function');
|
expect(Filer.FileSystem.providers.Default).to.be.a('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has Fallback constructor", function() {
|
it('has Fallback constructor', function() {
|
||||||
expect(Filer.FileSystem.providers.Fallback).to.be.a('function');
|
expect(Filer.FileSystem.providers.Fallback).to.be.a('function');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe('FileSystemShell.cat', function() {
|
||||||
|
|
||||||
shell.cat(null, function(error, data) {
|
shell.cat(null, function(error, data) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EINVAL");
|
expect(error.code).to.equal('EINVAL');
|
||||||
expect(data).not.to.exist;
|
expect(data).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ describe('FileSystemShell.cat', function() {
|
||||||
it('should return the contents of a single file', function(done) {
|
it('should return the contents of a single file', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var shell = new fs.Shell();
|
var shell = new fs.Shell();
|
||||||
var contents = "file contents";
|
var contents = 'file contents';
|
||||||
|
|
||||||
fs.writeFile('/file', contents, function(err) {
|
fs.writeFile('/file', contents, function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -41,7 +41,7 @@ describe('FileSystemShell.cat', function() {
|
||||||
it('should return the contents of multiple files', function(done) {
|
it('should return the contents of multiple files', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var shell = new fs.Shell();
|
var shell = new fs.Shell();
|
||||||
var contents = "file contents";
|
var contents = 'file contents';
|
||||||
var contents2 = contents + '\n' + contents;
|
var contents2 = contents + '\n' + contents;
|
||||||
|
|
||||||
fs.writeFile('/file', contents, function(err) {
|
fs.writeFile('/file', contents, function(err) {
|
||||||
|
@ -62,7 +62,7 @@ describe('FileSystemShell.cat', function() {
|
||||||
it('should fail if any of multiple file paths is invalid', function(done) {
|
it('should fail if any of multiple file paths is invalid', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var shell = new fs.Shell();
|
var shell = new fs.Shell();
|
||||||
var contents = "file contents";
|
var contents = 'file contents';
|
||||||
var contents2 = contents + '\n' + contents;
|
var contents2 = contents + '\n' + contents;
|
||||||
|
|
||||||
fs.writeFile('/file', contents, function(err) {
|
fs.writeFile('/file', contents, function(err) {
|
||||||
|
@ -73,7 +73,7 @@ describe('FileSystemShell.cat', function() {
|
||||||
|
|
||||||
shell.cat(['/file', '/nofile'], function(err, data) {
|
shell.cat(['/file', '/nofile'], function(err, data) {
|
||||||
expect(err).to.exist;
|
expect(err).to.exist;
|
||||||
expect(err.code).to.equal("ENOENT");
|
expect(err.code).to.equal('ENOENT');
|
||||||
expect(data).not.to.exist;
|
expect(data).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,7 +37,7 @@ describe('FileSystemShell.env', function() {
|
||||||
|
|
||||||
shell.cat(null, function(error, list) {
|
shell.cat(null, function(error, list) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EINVAL");
|
expect(error.code).to.equal('EINVAL');
|
||||||
expect(list).not.to.exist;
|
expect(list).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe('FileSystemShell.exec', function() {
|
||||||
it('should be able to execute a command .js file from the filesystem', function(done) {
|
it('should be able to execute a command .js file from the filesystem', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var shell = new fs.Shell();
|
var shell = new fs.Shell();
|
||||||
var cmdString = "fs.writeFile(args[0], args[1], callback);";
|
var cmdString = 'fs.writeFile(args[0], args[1], callback);';
|
||||||
|
|
||||||
fs.writeFile('/cmd.js', cmdString, function(error) {
|
fs.writeFile('/cmd.js', cmdString, function(error) {
|
||||||
if(error) throw error;
|
if(error) throw error;
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe('FileSystemShell.ls', function() {
|
||||||
|
|
||||||
shell.cat(null, function(error, list) {
|
shell.cat(null, function(error, list) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EINVAL");
|
expect(error.code).to.equal('EINVAL');
|
||||||
expect(list).not.to.exist;
|
expect(list).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -25,8 +25,8 @@ describe('FileSystemShell.ls', function() {
|
||||||
it('should return the contents of a simple dir', function(done) {
|
it('should return the contents of a simple dir', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var shell = new fs.Shell();
|
var shell = new fs.Shell();
|
||||||
var contents = "a";
|
var contents = 'a';
|
||||||
var contents2 = "bb";
|
var contents2 = 'bb';
|
||||||
|
|
||||||
fs.writeFile('/file', contents, function(err) {
|
fs.writeFile('/file', contents, function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -63,7 +63,7 @@ describe('FileSystemShell.ls', function() {
|
||||||
it('should return the shallow contents of a dir tree', function(done) {
|
it('should return the shallow contents of a dir tree', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var shell = new fs.Shell();
|
var shell = new fs.Shell();
|
||||||
var contents = "a";
|
var contents = 'a';
|
||||||
|
|
||||||
fs.mkdir('/dir', function(err) {
|
fs.mkdir('/dir', function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -119,7 +119,7 @@ describe('FileSystemShell.ls', function() {
|
||||||
it('should return the deep contents of a dir tree', function(done) {
|
it('should return the deep contents of a dir tree', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var shell = new fs.Shell();
|
var shell = new fs.Shell();
|
||||||
var contents = "a";
|
var contents = 'a';
|
||||||
|
|
||||||
fs.mkdir('/dir', function(err) {
|
fs.mkdir('/dir', function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe('FileSystemShell.rm', function() {
|
||||||
|
|
||||||
shell.rm(null, function(error, list) {
|
shell.rm(null, function(error, list) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal("EINVAL");
|
expect(error.code).to.equal('EINVAL');
|
||||||
expect(list).not.to.exist;
|
expect(list).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ describe('FileSystemShell.rm', function() {
|
||||||
it('should remove a single file', function(done) {
|
it('should remove a single file', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var shell = new fs.Shell();
|
var shell = new fs.Shell();
|
||||||
var contents = "a";
|
var contents = 'a';
|
||||||
|
|
||||||
fs.writeFile('/file', contents, function(err) {
|
fs.writeFile('/file', contents, function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -106,7 +106,7 @@ describe('FileSystemShell.rm', function() {
|
||||||
it('should work on a complex dir structure', function(done) {
|
it('should work on a complex dir structure', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
var shell = new fs.Shell();
|
var shell = new fs.Shell();
|
||||||
var contents = "a";
|
var contents = 'a';
|
||||||
|
|
||||||
fs.mkdir('/dir', function(err) {
|
fs.mkdir('/dir', function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
|
|
@ -4,8 +4,8 @@ var expect = require('chai').expect;
|
||||||
|
|
||||||
describe('node times (atime, mtime, ctime) with mount flags', function() {
|
describe('node times (atime, mtime, ctime) with mount flags', function() {
|
||||||
|
|
||||||
var dirname = "/dir";
|
var dirname = '/dir';
|
||||||
var filename = "/dir/file";
|
var filename = '/dir/file';
|
||||||
|
|
||||||
function memoryFS(flags, callback) {
|
function memoryFS(flags, callback) {
|
||||||
var name = util.uniqueName();
|
var name = util.uniqueName();
|
||||||
|
|
|
@ -6,8 +6,8 @@ describe('node times (atime, mtime, ctime)', function() {
|
||||||
beforeEach(util.setup);
|
beforeEach(util.setup);
|
||||||
afterEach(util.cleanup);
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
var dirname = "/dir";
|
var dirname = '/dir';
|
||||||
var filename = "/dir/file";
|
var filename = '/dir/file';
|
||||||
|
|
||||||
function createTree(callback) {
|
function createTree(callback) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
|
@ -287,7 +287,7 @@ describe('node times (atime, mtime, ctime)', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update ctime, atime, mtime of parent dir when calling fs.mkdir()', function(done) {
|
it('should update ctime, atime, mtime of parent dir when calling fs.mkdir()', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
|
|
||||||
createTree(function() {
|
createTree(function() {
|
||||||
stat('/', function(stats1) {
|
stat('/', function(stats1) {
|
||||||
|
|
Loading…
Reference in New Issue