Review fixes from PR #195

This commit is contained in:
Kieran Sedgwick 2014-05-26 12:30:17 -04:00
parent f0ac6ed32a
commit 4efa4a91f3
7 changed files with 45 additions and 17 deletions

1
.gitignore vendored
View File

@ -3,4 +3,3 @@ bower_components
.env .env
*~ *~
dist/filer-test.js dist/filer-test.js
/dist/filer_node-test.js

View File

@ -259,7 +259,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('develop', ['clean', 'requirejs:browser_develop', 'requirejs:node_develop']); grunt.registerTask('develop', ['clean', 'requirejs:browser_develop', 'requirejs:node_develop']);
grunt.registerTask('filer-test', ['clean', 'requirejs:node_test', 'requirejs:browser_test']); grunt.registerTask('filer-test', ['clean']);
grunt.registerTask('release', ['develop', 'uglify']); grunt.registerTask('release', ['develop', 'uglify']);
grunt.registerTask('check', ['jshint']); grunt.registerTask('check', ['jshint']);

View File

@ -46,10 +46,8 @@
"grunt-npm": "git://github.com/sedge/grunt-npm.git#branchcheck", "grunt-npm": "git://github.com/sedge/grunt-npm.git#branchcheck",
"grunt-prompt": "^1.1.0", "grunt-prompt": "^1.1.0",
"habitat": "^1.1.0", "habitat": "^1.1.0",
"semver": "^2.3.0",
"requirejs": "~2.1.11",
"mocha": "~1.18.2", "mocha": "~1.18.2",
"requirejs": "~2.1.11" "semver": "^2.3.0"
}, },
"main": "./src/index.js" "main": "./src/index.js"
} }

View File

@ -32,6 +32,10 @@ function nodeDownload(uri, callback) {
error = statusCode != 200 ? { message: err || 'Not found!', code: statusCode } : null; error = statusCode != 200 ? { message: err || 'Not found!', code: statusCode } : null;
if (error) {
return callback(error, null);
}
arrayBuffer = arrayLength && new ArrayBuffer(arrayLength); arrayBuffer = arrayLength && new ArrayBuffer(arrayLength);
// Convert buffer to Uint8Array // Convert buffer to Uint8Array
@ -42,7 +46,7 @@ function nodeDownload(uri, callback) {
} }
} }
callback(error, data); callback(null, data);
}); });
} }

View File

@ -1,7 +1,7 @@
var network = require('../../src/network.js'); var network = require('../../../src/network.js');
var expect = require('chai').expect; var expect = require('chai').expect;
describe('Network download tool', function() { describe('Network module', function() {
var uri; var uri;
if (typeof XMLHttpRequest === 'undefined') { if (typeof XMLHttpRequest === 'undefined') {
@ -20,13 +20,6 @@ describe('Network download tool', function() {
}; };
} }
it('should throw an exception when a URI is not passed', function(done) {
expect(function() {
network.download(undefined, function(error, data) {});
}).to.throwError;
done();
});
it('should get an error when a non-existent path is specified', function(done) { it('should get an error when a non-existent path is specified', function(done) {
network.download(uri.notFound, function(error, data) { network.download(uri.notFound, function(error, data) {
expect(error).to.exist; expect(error).to.exist;

32
tests/spec/providers/providers.memory.spec.js Executable file → Normal file
View File

@ -13,6 +13,38 @@ describe("Filer.FileSystem.providers.Memory", function() {
expect(memoryProvider.getReadWriteContext).to.be.a('function'); expect(memoryProvider.getReadWriteContext).to.be.a('function');
}); });
describe("Memory provider DBs are sharable", function() {
it("should share a single memory db when name is the same", function(done) {
var provider1;
var provider2;
var provider3;
var name1 = 'memory-db';
var name2 = 'memory-db2';
provider1 = new Filer.FileSystem.providers.Memory(name1);
provider1.open(function(error, firstAccess) {
expect(error).not.to.exist;
expect(firstAccess).to.be.true;
provider2 = new Filer.FileSystem.providers.Memory(name1);
provider2.open(function(error, firstAccess) {
expect(error).not.to.exist;
expect(firstAccess).to.be.false;
expect(provider1.db).to.equal(provider2.db);
provider3 = new Filer.FileSystem.providers.Memory(name2);
provider3.open(function(error, firstAccess) {
expect(error).not.to.exist;
expect(firstAccess).to.be.true;
expect(provider3.db).not.to.equal(provider2.db);
done();
});
});
});
});
});
describe("open an Memory provider", function() { describe("open an Memory provider", function() {
it("should open a new Memory database", function(done) { it("should open a new Memory database", function(done) {
var provider = new Filer.FileSystem.providers.Memory(); var provider = new Filer.FileSystem.providers.Memory();

View File

@ -36,12 +36,12 @@ 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/lib.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");
// Filer.FileSystemShell.* // Filer.FileSystemShell.*
require("./spec/shell/cd.spec"); require("./spec/shell/cd.spec");
@ -55,6 +55,9 @@ require("./spec/shell/mkdirp.spec");
require("./spec/shell/wget.spec"); require("./spec/shell/wget.spec");
require("./spec/shell/zip-unzip.spec"); require("./spec/shell/zip-unzip.spec");
// Custom Filer library modules
require("./spec/libs/network.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");
@ -64,4 +67,3 @@ 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("./spec/providers/providers.memory.spec");