Merge pull request #378 from humphd/karma

Automate tests using Headless Chrome + Karma runner
This commit is contained in:
Alan K 2018-08-21 14:54:48 -04:00 committed by GitHub
commit de45918cbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 2609 additions and 319 deletions

View File

@ -1,9 +1,16 @@
sudo: true
language: node_js language: node_js
node_js: node_js:
- "8.11.3" - "lts/*"
before_install: npm install -g grunt-cli
# Setup headless Chrome support
# https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-the-Chrome-addon-in-the-headless-mode
addons:
chrome: stable
before_install:
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
notifications: notifications:
email: false email: false
irc: "irc.mozilla.org#filer" irc: "irc.mozilla.org#filer"
env:
- "FILER_UPSTREAM_URI=\"default\" FILER_UPSTREAM_BRANCH=\"default\" FILER_UPSTREAM_REMOTE_NAME=\"default\""

View File

@ -17,10 +17,14 @@ npm install
You can now run the following `npm` scripts: You can now run the following `npm` scripts:
* `npm test` will build Filer and the tests in `tests/` and start a web server at http://localhost:1234 where you can run the tests. * `npm run lint` or `npm run eslint` will run `eslint` on the `src` and `tests` directories.
* `npm lint` will run `eslint` on the `src` and `tests` directories. * `npm run lint:fix` or `npm run eslint:fix` will run `eslint` with `--fix` on the `src` and `tests` directories, automatically fixing minor issues.
* `npm run test:manual` will build the tests, and allow you to run them in a browser manually by loading http://localhost:1234.
* `npm run karma-mocha` will build Filer and the tests, and finally run the tests in a headless Chrome browser.
* `npm test` will run `lint` followed by `karma-chrome`, and is what we do on Travis.
* `npm run build` will bundle two versions of Filer: `dist/filer.js` (unminified) and `dist/filer.min.js` (minified) as well as source map files. * `npm run build` will bundle two versions of Filer: `dist/filer.js` (unminified) and `dist/filer.min.js` (minified) as well as source map files.
Once you've done some hacking and you'd like to have your work merged, you'll need to Once you've done some hacking and you'd like to have your work merged, you'll need to
make a pull request. If you're patch includes code, make sure to check that all the make a pull request. If you're patch includes code, make sure to check that all the
unit tests pass, including any new tests you wrote. Finally, make sure you add yourself unit tests pass, including any new tests you wrote. Finally, make sure you add yourself

18
karma.conf.js Normal file
View File

@ -0,0 +1,18 @@
module.exports = function(config) {
config.set({
browsers: ['ChromeHeadless'],
singleRun: true,
basePath: '',
files: ['tests/dist/index.js'],
frameworks: ['mocha', 'chai'],
reporters: ['mocha'],
client: {
mocha: {
ui: 'bdd',
timeout: 5000,
slow: 250
}
}
});
};

2209
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -17,10 +17,17 @@
"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",
"test": "parcel tests/index.html --out-dir tests/dist", "lint:fix": "eslint --fix src tests",
"test:manual": "parcel tests/index.html --out-dir tests/dist",
"pretest": "npm run lint",
"test": "npm run karma-mocha",
"prebuild": "parcel build --global Filer src/index.js --no-minify --out-file filer.js", "prebuild": "parcel build --global Filer src/index.js --no-minify --out-file filer.js",
"build": "parcel build --global Filer src/index.js --out-file filer.min.js --detailed-report" "build": "parcel build --global Filer src/index.js --out-file filer.min.js --detailed-report",
"prekarma-mocha": "parcel build tests/index.js --no-source-maps --out-dir tests/dist",
"karma-mocha": "karma start karma.conf.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -33,6 +40,11 @@
"devDependencies": { "devDependencies": {
"chai": "^4.1.2", "chai": "^4.1.2",
"eslint": "^5.0.1", "eslint": "^5.0.1",
"karma": "^2.0.4",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"parcel-bundler": "^1.9.6" "parcel-bundler": "^1.9.6"
}, },

View File

@ -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);

View File

@ -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',

View File

@ -13,8 +13,6 @@ var NODE_TYPE_DIRECTORY = Constants.NODE_TYPE_DIRECTORY;
var NODE_TYPE_SYMBOLIC_LINK = Constants.NODE_TYPE_SYMBOLIC_LINK; var NODE_TYPE_SYMBOLIC_LINK = Constants.NODE_TYPE_SYMBOLIC_LINK;
var NODE_TYPE_META = Constants.NODE_TYPE_META; var NODE_TYPE_META = Constants.NODE_TYPE_META;
var DEFAULT_FILE_PERMISSIONS = Constants.DEFAULT_FILE_PERMISSIONS;
var DEFAULT_DIR_PERMISSIONS = Constants.DEFAULT_DIR_PERMISSIONS;
var FULL_READ_WRITE_EXEC_PERMISSIONS = Constants.FULL_READ_WRITE_EXEC_PERMISSIONS; var FULL_READ_WRITE_EXEC_PERMISSIONS = Constants.FULL_READ_WRITE_EXEC_PERMISSIONS;
var ROOT_DIRECTORY_NAME = Constants.ROOT_DIRECTORY_NAME; var ROOT_DIRECTORY_NAME = Constants.ROOT_DIRECTORY_NAME;
@ -25,7 +23,6 @@ var O_READ = Constants.O_READ;
var O_WRITE = Constants.O_WRITE; var O_WRITE = Constants.O_WRITE;
var O_CREATE = Constants.O_CREATE; var O_CREATE = Constants.O_CREATE;
var O_EXCLUSIVE = Constants.O_EXCLUSIVE; var O_EXCLUSIVE = Constants.O_EXCLUSIVE;
var O_TRUNCATE = Constants.O_TRUNCATE;
var O_APPEND = Constants.O_APPEND; var O_APPEND = Constants.O_APPEND;
var O_FLAGS = Constants.O_FLAGS; var O_FLAGS = Constants.O_FLAGS;
@ -843,7 +840,6 @@ function read_data(context, ofd, buffer, offset, length, position, callback) {
function stat_file(context, path, callback) { function stat_file(context, path, callback) {
path = normalize(path); path = normalize(path);
var name = basename(path);
find_node(context, path, callback); find_node(context, path, callback);
} }
@ -923,7 +919,7 @@ function link_node(context, oldpath, newpath, callback) {
} }
} }
function read_file_node(error, result) { function read_file_node(error) {
if(error) { if(error) {
callback(error); callback(error);
} else { } else {
@ -997,8 +993,12 @@ function unlink_node(context, path, callback) {
} else { } else {
delete directoryData[name]; delete directoryData[name];
context.putObject(directoryNode.data, directoryData, function(error) { context.putObject(directoryNode.data, directoryData, function(error) {
var now = Date.now(); if(error) {
update_node_times(context, parentPath, directoryNode, { mtime: now, ctime: now }, callback); callback(error);
} else {
var now = Date.now();
update_node_times(context, parentPath, directoryNode, { mtime: now, ctime: now }, callback);
}
}); });
} }
} }
@ -1021,7 +1021,11 @@ function unlink_node(context, path, callback) {
context.delete(fileNode.id, delete_file_data); context.delete(fileNode.id, delete_file_data);
} else { } else {
context.putObject(fileNode.id, fileNode, function(error) { context.putObject(fileNode.id, fileNode, function(error) {
update_node_times(context, path, fileNode, { ctime: Date.now() }, update_directory_data); if(error) {
callback(error);
} else {
update_node_times(context, path, fileNode, { ctime: Date.now() }, update_directory_data);
}
}); });
} }
} }
@ -1064,7 +1068,6 @@ function unlink_node(context, path, callback) {
function read_directory(context, path, callback) { function read_directory(context, path, callback) {
path = normalize(path); path = normalize(path);
var name = basename(path);
var directoryNode; var directoryNode;
var directoryData; var directoryData;
@ -1572,9 +1575,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;
@ -1784,7 +1787,7 @@ function readFile(fs, context, path, options, callback) {
var buffer = new Buffer(size); var buffer = new Buffer(size);
buffer.fill(0); buffer.fill(0);
read_data(context, ofd, buffer, 0, size, 0, function(err, nbytes) { read_data(context, ofd, buffer, 0, size, 0, function(err) {
cleanup(); cleanup();
if(err) { if(err) {
@ -1832,10 +1835,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);
} }
@ -1846,7 +1849,7 @@ function writeFile(fs, context, path, data, options, callback) {
var ofd = new OpenFileDescription(path, fileNode.id, flags, 0); var ofd = new OpenFileDescription(path, fileNode.id, flags, 0);
var fd = fs.allocDescriptor(ofd); var fd = fs.allocDescriptor(ofd);
replace_data(context, ofd, data, 0, data.length, function(err, nbytes) { replace_data(context, ofd, data, 0, data.length, function(err) {
fs.releaseDescriptor(fd); fs.releaseDescriptor(fd);
if(err) { if(err) {
@ -1869,10 +1872,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);
} }
@ -1883,7 +1886,7 @@ function appendFile(fs, context, path, data, options, callback) {
var ofd = new OpenFileDescription(path, fileNode.id, flags, fileNode.size); var ofd = new OpenFileDescription(path, fileNode.id, flags, fileNode.size);
var fd = fs.allocDescriptor(ofd); var fd = fs.allocDescriptor(ofd);
write_data(context, ofd, data, 0, data.length, ofd.position, function(err, nbytes) { write_data(context, ofd, data, 0, data.length, ofd.position, function(err) {
fs.releaseDescriptor(fd); fs.releaseDescriptor(fd);
if(err) { if(err) {
@ -1895,7 +1898,7 @@ function appendFile(fs, context, path, data, options, callback) {
} }
function exists(fs, context, path, callback) { function exists(fs, context, path, callback) {
function cb(err, stats) { function cb(err) {
callback(err ? false : true); callback(err ? false : true);
} }
stat(fs, context, path, cb); stat(fs, context, path, cb);
@ -1903,7 +1906,6 @@ function exists(fs, context, path, callback) {
// Based on https://github.com/nodejs/node/blob/c700cc42da9cf73af9fec2098520a6c0a631d901/lib/internal/validators.js#L21 // Based on https://github.com/nodejs/node/blob/c700cc42da9cf73af9fec2098520a6c0a631d901/lib/internal/validators.js#L21
var octalReg = /^[0-7]+$/; var octalReg = /^[0-7]+$/;
var modeDesc = 'must be a 32-bit unsigned integer or an octal string';
function isUint32(value) { function isUint32(value) {
return value === (value >>> 0); return value === (value >>> 0);
} }

View File

@ -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) {
@ -42,6 +42,7 @@ function maybeCallback(callback) {
// Default callback that logs an error if passed in // Default callback that logs an error if passed in
function defaultCallback(err) { function defaultCallback(err) {
if(err) { if(err) {
/* eslint no-console: 0 */
console.error('Filer error: ', err); console.error('Filer error: ', err);
} }
} }
@ -104,7 +105,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) {

View File

@ -1,9 +1,6 @@
var NODE_TYPE_FILE = require('./constants.js').NODE_TYPE_FILE; var NODE_TYPE_FILE = require('./constants.js').NODE_TYPE_FILE;
var NODE_TYPE_DIRECTORY = require('./constants.js').NODE_TYPE_DIRECTORY; var NODE_TYPE_DIRECTORY = require('./constants.js').NODE_TYPE_DIRECTORY;
var NODE_TYPE_SYMBOLIC_LINK = require('./constants.js').NODE_TYPE_SYMBOLIC_LINK; var NODE_TYPE_SYMBOLIC_LINK = require('./constants.js').NODE_TYPE_SYMBOLIC_LINK;
var NODE_TYPE_META = require('./constants.js').NODE_TYPE_META;
var ROOT_DIRECTORY_NAME = require('./constants.js').ROOT_DIRECTORY_NAME;
var S_IFREG = require('./constants.js').S_IFREG; var S_IFREG = require('./constants.js').S_IFREG;
var S_IFDIR = require('./constants.js').S_IFDIR; var S_IFDIR = require('./constants.js').S_IFDIR;
@ -14,15 +11,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;
} }
} }

View File

@ -54,7 +54,7 @@ function normalizeArray(parts, allowAboveRoot) {
// Split a filename into [root, dir, basename, ext], unix version // Split a filename into [root, dir, basename, ext], unix version
// 'root' is just a slash, or nothing. // 'root' is just a slash, or nothing.
var splitPathRe = var splitPathRe =
/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/; /^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^./]*)?)$/;
var splitPath = function(filename) { var splitPath = function(filename) {
var result = splitPathRe.exec(filename); var result = splitPathRe.exec(filename);
return [result[1] || '', result[2] || '', result[3] || '', result[4] || '']; return [result[1] || '', result[2] || '', result[3] || '', result[4] || ''];
@ -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
@ -91,8 +91,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) === '/';
// Normalize the path // Normalize the path
path = normalizeArray(path.split('/').filter(function(p) { path = normalizeArray(path.split('/').filter(function(p) {
@ -113,7 +112,7 @@ function normalize(path) {
function join() { function join() {
var paths = Array.prototype.slice.call(arguments, 0); var paths = Array.prototype.slice.call(arguments, 0);
return normalize(paths.filter(function(p, index) { return normalize(paths.filter(function(p) {
return p && typeof p === 'string'; return p && typeof p === 'string';
}).join('/')); }).join('/'));
} }
@ -151,7 +150,7 @@ function relative(from, to) {
} }
var outputParts = []; var outputParts = [];
for (var i = samePartsLength; i < fromParts.length; i++) { for (i = samePartsLength; i < fromParts.length; i++) {
outputParts.push('..'); outputParts.push('..');
} }
@ -162,8 +161,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 +184,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) {

View File

@ -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;

View File

@ -2,7 +2,6 @@ var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME;
var FILE_STORE_NAME = require('../constants.js').FILE_STORE_NAME; var FILE_STORE_NAME = require('../constants.js').FILE_STORE_NAME;
var IDB_RW = require('../constants.js').IDB_RW; var IDB_RW = require('../constants.js').IDB_RW;
var IDB_RO = require('../constants.js').IDB_RO; var IDB_RO = require('../constants.js').IDB_RO;
var Errors = require('../errors.js');
var FilerBuffer = require('../buffer.js'); var FilerBuffer = require('../buffer.js');
var indexedDB = global.indexedDB || var indexedDB = global.indexedDB ||

View File

@ -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;
} }

View File

@ -26,12 +26,12 @@ WebSQLContext.prototype.clear = function(callback) {
function onError(transaction, error) { function onError(transaction, error) {
callback(error); callback(error);
} }
function onSuccess(transaction, result) { function onSuccess() {
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) {
@ -83,15 +83,15 @@ WebSQLContext.prototype.getBuffer = function(key, callback) {
}; };
function _put(getTransaction, key, value, callback) { function _put(getTransaction, key, value, callback) {
function onSuccess(transaction, result) { function onSuccess() {
callback(null); callback(null);
} }
function onError(transaction, error) { function onError(transaction, error) {
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) {
@ -104,15 +104,15 @@ WebSQLContext.prototype.putBuffer = function(key, uint8BackedBuffer, callback) {
}; };
WebSQLContext.prototype.delete = function(key, callback) { WebSQLContext.prototype.delete = function(key, callback) {
function onSuccess(transaction, result) { function onSuccess() {
callback(null); callback(null);
} }
function onError(transaction, error) { function onError(transaction, error) {
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;
} }
@ -145,7 +145,7 @@ WebSQL.prototype.open = function(callback) {
} }
callback(error); callback(error);
} }
function onSuccess(transaction, result) { function onSuccess() {
that.db = db; that.db = db;
callback(); callback();
} }
@ -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() {

View File

@ -2,7 +2,6 @@ var Path = require('../path.js');
var Errors = require('../errors.js'); var Errors = require('../errors.js');
var Environment = require('./environment.js'); var Environment = require('./environment.js');
var async = require('../../lib/async.js'); var async = require('../../lib/async.js');
var Encoding = require('../encoding.js');
var minimatch = require('minimatch'); var minimatch = require('minimatch');
function Shell(fs, options) { function Shell(fs, options) {
@ -87,7 +86,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;
@ -131,7 +130,7 @@ Shell.prototype.touch = function(path, options, callback) {
fs.utimes(path, atime, mtime, callback); fs.utimes(path, atime, mtime, callback);
} }
fs.stat(path, function(error, stats) { fs.stat(path, function(error) {
if(error) { if(error) {
if(options.updateOnly === true) { if(options.updateOnly === true) {
callback(); callback();
@ -348,7 +347,7 @@ Shell.prototype.tempDir = function(callback) {
// Try and create it, and it will either work or fail // Try and create it, and it will either work or fail
// but either way it's now there. // but either way it's now there.
fs.mkdir(tmp, function(err) { fs.mkdir(tmp, function() {
callback(null, tmp); callback(null, tmp);
}); });
}; };
@ -432,7 +431,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') {

View File

@ -52,7 +52,7 @@ describe('Queued operations should error when fs is in error state, issue 258',
it('should get EFILESYSTEMERROR errors on callbacks to queued operations on provider error', function(done) { it('should get EFILESYSTEMERROR errors on callbacks to queued operations on provider error', function(done) {
var errCount = 0; var errCount = 0;
var fs = new Filer.FileSystem({provider: provider}, function(err) { var fs = new Filer.FileSystem({provider: provider}, function() {
// Do nothing // Do nothing
}); });

View File

@ -14,6 +14,7 @@ describe('fs.readdir on non-dir paths, issue 267', function() {
fs.readdir('/myfile.txt', function(err, contents) { fs.readdir('/myfile.txt', function(err, contents) {
expect(err).to.exist; expect(err).to.exist;
expect(err.code).to.equal('ENOTDIR'); expect(err.code).to.equal('ENOTDIR');
expect(contents).not.to.exist;
done(); done();
}); });
}); });

View File

@ -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() {

View File

@ -46,7 +46,7 @@ describe('sh.ls and deep directory trees', function() {
} }
async.eachSeries(paths, writeFile, function(err) { async.eachSeries(paths, writeFile, function(err) {
if(err) { console.log('error', err); throw err; } if(err) throw err;
sh.ls('/', {recursive: true}, function(err, listing) { sh.ls('/', {recursive: true}, function(err, listing) {
expect(err).not.to.exist; expect(err).not.to.exist;

View File

@ -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');

View File

@ -40,7 +40,8 @@ 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); /* eslint no-console:0 */
console.log('Failed to delete test database', e);
finished(); finished();
} }
} }

View File

@ -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;
} }

View File

@ -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() {

View File

@ -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);

View File

@ -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');
}); });
}); });

View File

@ -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;
@ -69,13 +69,11 @@ describe('fs.appendFile', function() {
it('should append a binary file', function(done) { it('should append 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: '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 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 +92,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 +112,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;

View File

@ -1,4 +1,3 @@
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;

View File

@ -1,4 +1,3 @@
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;
@ -12,7 +11,7 @@ describe('fs.chown, fs.fchown', function() {
expect(typeof fs.fchown).to.equal('function'); expect(typeof fs.fchown).to.equal('function');
}); });
it('should automatically set a file\s uid and gid to 0 (i.e., root)', function(done) { it('should automatically set a file\'s uid and gid to 0 (i.e., root)', function(done) {
var fs = util.fs(); var fs = util.fs();
fs.open('/file', 'w', function(err, fd) { fs.open('/file', 'w', function(err, fd) {

View File

@ -20,8 +20,11 @@ describe('fs.close', function() {
var fd = result; var fd = result;
fs.close(fd, function(error) { fs.close(fd, function(error) {
if(error) throw error;
fs.read(fd, buffer, 0, buffer.length, undefined, function(error, result) { fs.read(fd, buffer, 0, buffer.length, undefined, function(error, result) {
expect(error).to.exist; expect(error).to.exist;
expect(result).not.to.exist;
done(); done();
}); });
}); });

View File

@ -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;
@ -70,13 +70,17 @@ describe('fs.link', function() {
fs.stat('/', function (error, result) { fs.stat('/', function (error, result) {
if (error) throw error; if (error) throw error;
var _oldstats = result; expect(result).to.exist;
fs.symlink('/', '/myfileLink', function (error) { fs.symlink('/', '/myfileLink', function (error) {
if (error) throw error; if (error) throw error;
fs.link('/myfileLink', '/myotherfile', function (error) { fs.link('/myfileLink', '/myotherfile', function (error) {
if (error) throw error; if (error) throw error;
fs.lstat('/myfileLink', function (error, result) { fs.lstat('/myfileLink', function (error, result) {
if (error) throw error; if (error) throw error;
var _linkstats = result; var _linkstats = result;
fs.lstat('/myotherfile', function (error, result) { fs.lstat('/myotherfile', function (error, result) {
expect(error).not.to.exist; expect(error).not.to.exist;

View File

@ -28,9 +28,11 @@ describe('fs.lseek', function() {
fs.stat('/myfile', function (error, result) { fs.stat('/myfile', function (error, result) {
expect(error).not.to.exist; expect(error).not.to.exist;
expect(result).to.exist;
fs.lstat('/myFileLink', function (error, result) { fs.lstat('/myFileLink', function (error, result) {
expect(error).to.exist; expect(error).to.exist;
expect(result).not.to.exist;
fs.stat('/myOtherFileLink', function (error, result) { fs.stat('/myOtherFileLink', function (error, result) {
if (error) throw error; if (error) throw error;
@ -57,6 +59,7 @@ describe('fs.lseek', function() {
fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) { fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(buffer.length);
fs.lseek(fd, offset, 'SET', function(error, result) { fs.lseek(fd, offset, 'SET', function(error, result) {
expect(error).not.to.exist; expect(error).not.to.exist;
@ -64,9 +67,11 @@ describe('fs.lseek', function() {
fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) { fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(buffer.length);
fs.read(fd, result_buffer, 0, result_buffer.length, 0, function(error, result) { fs.read(fd, result_buffer, 0, result_buffer.length, 0, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(result_buffer.length);
fs.stat('/myfile', function(error, result) { fs.stat('/myfile', function(error, result) {
if(error) throw error; if(error) throw error;
@ -95,6 +100,7 @@ describe('fs.lseek', function() {
fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) { fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(buffer.length);
fs.lseek(fd, offset, 'CUR', function(error, result) { fs.lseek(fd, offset, 'CUR', function(error, result) {
expect(error).not.to.exist; expect(error).not.to.exist;
@ -102,9 +108,11 @@ describe('fs.lseek', function() {
fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) { fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(buffer.length);
fs.read(fd, result_buffer, 0, result_buffer.length, 0, function(error, result) { fs.read(fd, result_buffer, 0, result_buffer.length, 0, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(result_buffer.length);
fs.stat('/myfile', function(error, result) { fs.stat('/myfile', function(error, result) {
if(error) throw error; if(error) throw error;
@ -133,6 +141,7 @@ describe('fs.lseek', function() {
var fd1 = result; var fd1 = result;
fs.write(fd1, buffer, 0, buffer.length, undefined, function(error, result) { fs.write(fd1, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(buffer.length);
fs.open('/myfile', 'w+', function(error, result) { fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error; if(error) throw error;
@ -144,6 +153,7 @@ describe('fs.lseek', function() {
fs.write(fd2, buffer, 0, buffer.length, undefined, function(error, result) { fs.write(fd2, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(buffer.length);
fs.stat('/myfile', function(error, result) { fs.stat('/myfile', function(error, result) {
if(error) throw error; if(error) throw error;
@ -153,6 +163,8 @@ describe('fs.lseek', function() {
result_buffer.fill(0); result_buffer.fill(0);
fs.read(fd2, result_buffer, 0, result_buffer.length, 0, function(error, result) { fs.read(fd2, result_buffer, 0, result_buffer.length, 0, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(result_buffer.length);
var expected = new Filer.Buffer([1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8]); var expected = new Filer.Buffer([1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8]);
expect(result_buffer).to.deep.equal(expected); expect(result_buffer).to.deep.equal(expected);
done(); done();

View File

@ -12,11 +12,10 @@ describe('fs.lstat', function() {
it('should return an error if path does not exist', function(done) { it('should return an error if path does not exist', function(done) {
var fs = util.fs(); var fs = util.fs();
var _error, _result;
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();
}); });

View File

@ -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();
}); });
}); });

View File

@ -32,9 +32,10 @@ describe('fs.mknod', function() {
it('should return an error if the parent node is not a directory', function(done) { it('should return an error if the parent node is not a directory', function(done) {
var fs = util.fs(); var fs = util.fs();
fs.mknod('/file', 'FILE' , function(error, result) { fs.mknod('/file', 'FILE' , function(error) {
if(error) throw error; if(error) throw error;
fs.mknod('/file/myfile', 'FILE', function(error, result) {
fs.mknod('/file/myfile', 'FILE', function(error) {
expect(error.code).to.equal('ENOTDIR'); expect(error.code).to.equal('ENOTDIR');
done(); done();
}); });
@ -68,8 +69,9 @@ describe('fs.mknod', function() {
it('should make a new file', function(done) { it('should make a new file', function(done) {
var fs = util.fs(); var fs = util.fs();
fs.mknod('/file', 'FILE' , function(error, result) { fs.mknod('/file', 'FILE' , function(error) {
if(error) throw error; if(error) throw error;
fs.stat('/file', function(error, result) { fs.stat('/file', function(error, result) {
expect(error).not.to.exist; expect(error).not.to.exist;
expect(result.type).to.equal('FILE'); expect(result.type).to.equal('FILE');

View File

@ -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();
}); });
@ -83,7 +83,6 @@ describe('fs.open', function() {
it('should return the argument value of the file descriptor index matching the value set by the first useable file descriptor constant', function(done) { it('should return the argument value of the file descriptor index matching the value set by the first useable file descriptor constant', function(done) {
var fs = util.fs(); var fs = util.fs();
var firstFD = constants.FIRST_DESCRIPTOR; var firstFD = constants.FIRST_DESCRIPTOR;
var fd1;
fs.open('/file1', 'w+', function(error, fd) { fs.open('/file1', 'w+', function(error, fd) {
if(error) throw error; if(error) throw error;
@ -95,8 +94,9 @@ describe('fs.open', function() {
it('should create a new file when flagged for write', function(done) { it('should create a new file when flagged for write', function(done) {
var fs = util.fs(); var fs = util.fs();
fs.open('/myfile', 'w', function(error, result) { fs.open('/myfile', 'w', function(error) {
if(error) throw error; if(error) throw error;
fs.stat('/myfile', function(error, result) { fs.stat('/myfile', function(error, result) {
expect(error).not.to.exist; expect(error).not.to.exist;
expect(result).to.exist; expect(result).to.exist;

View File

@ -21,6 +21,7 @@ describe('fs.read', function() {
if(error) throw error; if(error) throw error;
fs.write(fd, wbuffer, 0, wbuffer.length, 0, function(error, result) { fs.write(fd, wbuffer, 0, wbuffer.length, 0, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(wbuffer.length);
fs.read(fd, rbuffer, 0, rbuffer.length, 0, function(error, result) { fs.read(fd, rbuffer, 0, rbuffer.length, 0, function(error, result) {
expect(error).not.to.exist; expect(error).not.to.exist;
@ -44,6 +45,7 @@ describe('fs.read', function() {
fs.write(fd, wbuffer, 0, wbuffer.length, 0, function(error, result) { fs.write(fd, wbuffer, 0, wbuffer.length, 0, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(wbuffer.length);
fs.read(fd, rbuffer, 0, rbuffer.length / 2, undefined, function(error, result) { fs.read(fd, rbuffer, 0, rbuffer.length / 2, undefined, function(error, result) {
if(error) throw error; if(error) throw error;
@ -70,7 +72,7 @@ describe('fs.read', function() {
buf2.fill(0); buf2.fill(0);
fs.mkdir('/mydir', function(error) { fs.mkdir('/mydir', function(error) {
if(error) throw err; if(error) throw error;
fs.open('/mydir', 'r', function(error, fd) { fs.open('/mydir', 'r', function(error, fd) {
if(error) throw error; if(error) throw error;

View File

@ -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();
}); });

View File

@ -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();
}); });
}); });

View File

@ -32,6 +32,7 @@ describe('fs.rename', function() {
fs.stat('/myfile', function(error, result) { fs.stat('/myfile', function(error, result) {
expect(error).to.exist; expect(error).to.exist;
expect(result).not.to.exist;
complete1 = true; complete1 = true;
maybeDone(); maybeDone();
}); });

View File

@ -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();
}); });
}); });

View File

@ -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();
}); });
}); });

View File

@ -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);

View File

@ -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();
}); });

View File

@ -43,8 +43,10 @@ describe('fs.stats', function() {
fs.open('/myfile', 'w+', function(error, fd) { fs.open('/myfile', 'w+', function(error, fd) {
if(error) throw error; if(error) throw error;
fs.close(fd, function(error, stats) {
fs.close(fd, function(error) {
if(error) throw error; if(error) throw error;
fs.symlink('/myfile', '/myfilelink', function(error) { fs.symlink('/myfile', '/myfilelink', function(error) {
if(error) throw error; if(error) throw error;
fs.lstat('/myfilelink', function(error, stats) { fs.lstat('/myfilelink', function(error, stats) {
@ -97,7 +99,7 @@ describe('fs.stats', function() {
fs.open('/myfile', 'w+', function(error, fd) { fs.open('/myfile', 'w+', function(error, fd) {
if(error) throw error; if(error) throw error;
fs.close(fd, function(error, stats) { fs.close(fd, function(error) {
if(error) throw error; if(error) throw error;
fs.symlink('/myfile', '/myfilelink', function(error) { fs.symlink('/myfile', '/myfilelink', function(error) {
if(error) throw error; if(error) throw error;
@ -197,7 +199,7 @@ describe('fs.stats', function() {
fs.open('/myfile', 'w+', function(error, fd) { fs.open('/myfile', 'w+', function(error, fd) {
if(error) throw error; if(error) throw error;
fs.close(fd, function(error, stats) { fs.close(fd, function(error) {
if(error) throw error; if(error) throw error;
fs.symlink('/myfile', '/myfilelink', function(error) { fs.symlink('/myfile', '/myfilelink', function(error) {
if(error) throw error; if(error) throw error;
@ -274,7 +276,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 +292,7 @@ describe('fs.stats', function() {
expect(stats.name).to.equal(Path.basename(filepath)); expect(stats.name).to.equal(Path.basename(filepath));
done(); done();
}); });
}) });
}); });
}) });
}); });

View File

@ -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();
}); });
}); });

View File

@ -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();
}); });
}); });
@ -46,6 +46,7 @@ describe('fs.truncate', function() {
var fd = result; var fd = result;
fs.write(fd, buffer, 0, buffer.length, 0, function(error, result) { fs.write(fd, buffer, 0, buffer.length, 0, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(buffer.length);
fs.close(fd, function(error) { fs.close(fd, function(error) {
if(error) throw error; if(error) throw error;
@ -76,6 +77,7 @@ describe('fs.truncate', function() {
var fd = result; var fd = result;
fs.write(fd, buffer, 0, buffer.length, 0, function(error, result) { fs.write(fd, buffer, 0, buffer.length, 0, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(buffer.length);
fs.close(fd, function(error) { fs.close(fd, function(error) {
if(error) throw error; if(error) throw error;
@ -105,6 +107,7 @@ describe('fs.truncate', function() {
var fd = result; var fd = result;
fs.write(fd, buffer, 0, buffer.length, 0, function(error, result) { fs.write(fd, buffer, 0, buffer.length, 0, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(buffer.length);
fs.close(fd, function(error) { fs.close(fd, function(error) {
if(error) throw error; if(error) throw error;
@ -134,6 +137,7 @@ describe('fs.truncate', function() {
var fd = result; var fd = result;
fs.write(fd, buffer, 0, buffer.length, 0, function(error, result) { fs.write(fd, buffer, 0, buffer.length, 0, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(buffer.length);
fs.ftruncate(fd, 0, function(error) { fs.ftruncate(fd, 0, function(error) {
expect(error).not.to.exist; expect(error).not.to.exist;
@ -159,6 +163,7 @@ describe('fs.truncate', function() {
var fd = result; var fd = result;
fs.write(fd, buffer, 0, buffer.length, 0, function(error, result) { fs.write(fd, buffer, 0, buffer.length, 0, function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.equal(buffer.length);
fs.close(fd, function(error) { fs.close(fd, function(error) {
if(error) throw error; if(error) throw error;

View File

@ -34,6 +34,7 @@ describe('fs.unlink', function() {
fs.stat('/myfile', function(error, result) { fs.stat('/myfile', function(error, result) {
expect(error).to.exist; expect(error).to.exist;
expect(result).not.to.exist;
complete1 = true; complete1 = true;
maybeDone(); maybeDone();
}); });
@ -65,6 +66,7 @@ describe('fs.unlink', function() {
fs.lstat('/myFileLink', function (error, result) { fs.lstat('/myFileLink', function (error, result) {
expect(error).to.exist; expect(error).to.exist;
expect(result).not.to.exist;
fs.lstat('/myotherfile', function (error, result) { fs.lstat('/myotherfile', function (error, result) {
if (error) throw error; if (error) throw error;

View File

@ -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();
}); });
}); });
}); });
@ -154,8 +154,6 @@ describe('fs.utimes', function() {
it('should update atime and mtime using current time if arguments are null', function(done) { it('should update atime and mtime using current time if arguments are null', function(done) {
var fs = util.fs(); var fs = util.fs();
var atimeEst;
var mtimeEst;
fs.writeFile('/myfile', '', function (error) { fs.writeFile('/myfile', '', function (error) {
if (error) throw error; if (error) throw error;

View File

@ -13,11 +13,10 @@ 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.";
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 +24,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 +38,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 +52,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;
@ -67,8 +66,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: '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 +81,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;

View File

@ -97,6 +97,7 @@ describe('fs.xattr', function() {
fs.getxattr('/testfile', '', function(error, value) { fs.getxattr('/testfile', '', function(error, value) {
expect(error).to.exist; expect(error).to.exist;
expect(error.code).to.equal('EINVAL'); expect(error.code).to.equal('EINVAL');
expect(value).not.to.exist;
done(); done();
}); });
}); });
@ -111,6 +112,7 @@ describe('fs.xattr', function() {
fs.getxattr('/testfile', 89, function(error, value) { fs.getxattr('/testfile', 89, function(error, value) {
expect(error).to.exist; expect(error).to.exist;
expect(error.code).to.equal('EINVAL'); expect(error.code).to.equal('EINVAL');
expect(value).not.to.exist;
done(); done();
}); });
}); });
@ -125,6 +127,7 @@ describe('fs.xattr', function() {
fs.getxattr('/testfile', 'test', function(error, value) { fs.getxattr('/testfile', 'test', function(error, value) {
expect(error).to.exist; expect(error).to.exist;
expect(error.code).to.equal('ENOATTR'); expect(error.code).to.equal('ENOATTR');
expect(value).not.to.exist;
done(); done();
}); });
}); });
@ -132,10 +135,9 @@ describe('fs.xattr', function() {
it('should error when file descriptor is invalid', function(done) { it('should error when file descriptor is invalid', function(done) {
var fs = util.fs(); var fs = util.fs();
var completeSet, completeGet, completeRemove; var completeSet = false;
var _value; var completeGet = false;
var completeRemove = false;
completeSet = completeGet = completeRemove = false;
function maybeDone() { function maybeDone() {
if(completeSet && completeGet && completeRemove) { if(completeSet && completeGet && completeRemove) {
@ -161,6 +163,7 @@ describe('fs.xattr', function() {
fs.fremovexattr(1, 'test', function(error, value) { fs.fremovexattr(1, 'test', function(error, value) {
expect(error).to.exist; expect(error).to.exist;
expect(error.code).to.equal('EBADF'); expect(error.code).to.equal('EBADF');
expect(value).not.to.exist;
completeRemove = true; completeRemove = true;
maybeDone(); maybeDone();
}); });
@ -288,7 +291,7 @@ describe('fs.xattr', function() {
}); });
}); });
}); });
}) });
}); });
}); });

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);
@ -27,6 +27,7 @@ describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/
watcher.close(); watcher.close();
fs.writeFile(filenameOne, 'hello again', function(error) { fs.writeFile(filenameOne, 'hello again', function(error) {
if(error) throw error;
expect(changes).to.equal(1); expect(changes).to.equal(1);
done(); done();
}); });
@ -37,7 +38,6 @@ describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/
it('should get change event for writeFile() using fs.watch() only', function(done) { it('should get change event for writeFile() using fs.watch() only', function(done) {
var fs = util.fs(); var fs = util.fs();
var changes = 0;
var watcher = fs.watch(filenameTwo, function(event, filename) { var watcher = fs.watch(filenameTwo, function(event, filename) {
expect(event).to.equal('change'); expect(event).to.equal('change');
@ -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();

View File

@ -32,6 +32,8 @@ describe('path resolution', function() {
var fs = util.fs(); var fs = util.fs();
fs.mkdir('/mydir', function(error) { fs.mkdir('/mydir', function(error) {
if(error) throw error;
fs.symlink('/mydir', '/mydirectorylink', function(error) { fs.symlink('/mydir', '/mydirectorylink', function(error) {
if(error) throw error; if(error) throw error;
@ -121,7 +123,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();
}); });
@ -148,6 +150,7 @@ describe('path resolution', function() {
if(error) throw error; if(error) throw error;
fs.stat('/myfile0', function(error, result) { fs.stat('/myfile0', function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.exist;
createSymlinkChain(1, function() { createSymlinkChain(1, function() {
fs.stat('/myfile11', function(error, result) { fs.stat('/myfile11', function(error, result) {
@ -201,6 +204,7 @@ describe('path resolution', function() {
if(error) throw error; if(error) throw error;
fs.stat('/myfile', function(error, result) { fs.stat('/myfile', function(error, result) {
if(error) throw error; if(error) throw error;
expect(result).to.exist;
fs.open('/myfile2', 'w', function(error, result) { fs.open('/myfile2', 'w', function(error, result) {
if(error) throw error; if(error) throw error;
@ -212,7 +216,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();
}); });

View File

@ -1,3 +1,5 @@
/* eslint no-console: 0 */
var Buffer = require('../../../src').Buffer; var Buffer = require('../../../src').Buffer;
var util = require('../../lib/test-utils.js'); var util = require('../../lib/test-utils.js');
var expect = require('chai').expect; var expect = require('chai').expect;
@ -8,11 +10,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 +31,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) {
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 +59,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 +72,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) {
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 +92,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) {
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 +112,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) {
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 +134,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) {
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(error) {
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();

View File

@ -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');
}); });
}); });

View File

@ -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();
}); });

View File

@ -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();
}); });

View File

@ -13,12 +13,12 @@ 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;
shell.exec('/cmd.js', ['/test', 'hello world'], function(error, result) { shell.exec('/cmd.js', ['/test', 'hello world'], function(error) {
if(error) throw error; if(error) throw error;
fs.readFile('/test', 'utf8', function(error, data) { fs.readFile('/test', 'utf8', function(error, data) {

View File

@ -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;

View File

@ -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;

View File

@ -41,6 +41,7 @@ describe('FileSystemShell.touch', function() {
fs.stat('/newfile', function(error, stats) { fs.stat('/newfile', function(error, stats) {
expect(error).to.exist; expect(error).to.exist;
expect(stats).not.to.exist;
done(); done();
}); });
}); });

View File

@ -4,12 +4,12 @@ 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();
var fs = new Filer.FileSystem({ return new Filer.FileSystem({
name: name, name: name,
flags: flags || [], flags: flags || [],
provider: new Filer.FileSystem.providers.Memory(name) provider: new Filer.FileSystem.providers.Memory(name)

View File

@ -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) {
@ -364,6 +364,7 @@ describe('node times (atime, mtime, ctime)', function() {
stat('/myfile', function(stats1) { stat('/myfile', function(stats1) {
fs.write(fd, buffer, 0, buffer.length, 0, function(error, nbytes) { fs.write(fd, buffer, 0, buffer.length, 0, function(error, nbytes) {
if(error) throw error; if(error) throw error;
expect(nbytes).to.equal(buffer.length);
fs.close(fd, function(error) { fs.close(fd, function(error) {
if(error) throw error; if(error) throw error;
@ -391,6 +392,7 @@ describe('node times (atime, mtime, ctime)', function() {
fs.write(fd, buffer, 0, buffer.length, 0, function(err, nbytes) { fs.write(fd, buffer, 0, buffer.length, 0, function(err, nbytes) {
if(err) throw err; if(err) throw err;
expect(nbytes).to.equal(buffer.length);
fs.close(fd, function(error) { fs.close(fd, function(error) {
if(error) throw error; if(error) throw error;
@ -402,6 +404,8 @@ describe('node times (atime, mtime, ctime)', function() {
var buffer2 = new Filer.Buffer(buffer.length); var buffer2 = new Filer.Buffer(buffer.length);
buffer2.fill(0); buffer2.fill(0);
fs.read(fd, buffer2, 0, buffer2.length, 0, function(err, nbytes) { fs.read(fd, buffer2, 0, buffer2.length, 0, function(err, nbytes) {
if(err) throw err;
expect(nbytes).to.equal(buffer2.length);
fs.close(fd, function(error) { fs.close(fd, function(error) {
if(error) throw error; if(error) throw error;
@ -429,6 +433,7 @@ describe('node times (atime, mtime, ctime)', function() {
stat(filename, function(stats1) { stat(filename, function(stats1) {
fs.readFile(filename, function(error, data) { fs.readFile(filename, function(error, data) {
if(error) throw error; if(error) throw error;
expect(data).to.exist;
stat(filename, function(stats2) { stat(filename, function(stats2) {
expect(stats2.ctime).to.equal(stats1.ctime); expect(stats2.ctime).to.equal(stats1.ctime);
@ -531,6 +536,7 @@ describe('node times (atime, mtime, ctime)', function() {
stat(filename, function(stats1) { stat(filename, function(stats1) {
fs.getxattr(filename, 'extra', function(error, value) { fs.getxattr(filename, 'extra', function(error, value) {
if(error) throw error; if(error) throw error;
expect(value).to.equal('data');
stat(filename, function(stats2) { stat(filename, function(stats2) {
expect(stats2.ctime).to.equal(stats1.ctime); expect(stats2.ctime).to.equal(stats1.ctime);
@ -557,6 +563,7 @@ describe('node times (atime, mtime, ctime)', function() {
stat(filename, function(stats1) { stat(filename, function(stats1) {
fs.fgetxattr(fd, 'extra', function(error, value) { fs.fgetxattr(fd, 'extra', function(error, value) {
if(error) throw error; if(error) throw error;
expect(value).to.equal('data');
stat(filename, function(stats2) { stat(filename, function(stats2) {
expect(stats2.ctime).to.equal(stats1.ctime); expect(stats2.ctime).to.equal(stats1.ctime);