Skip to content

Commit

Permalink
passing test suite now
Browse files Browse the repository at this point in the history
  • Loading branch information
Niall O'Higgins committed Oct 30, 2013
1 parent 189c87b commit 322769d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 128 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ lint:
@echo "Linted"

test-only:
@echo "No tests"
@./node_modules/.bin/mocha -R tap

.PHONY: test test-only lint
127 changes: 0 additions & 127 deletions test/test_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,94 +182,6 @@ describe("#Loader", function() {
});
});
});

it("should continue without extensions", function(done) {
var emitter = new EventEmitter();
var config = {};
var appInstance = {
use: function() { },
get: function(p, f) {},
post: function(p, f) {},
delete: function(p, f) {},
put: function(p, f) {},
};
var context = {
config: config,
emitter: emitter,
extensionRoutes: [],
};
loader.initWebAppExtensions("/tmp/nonexistant", context, appInstance, function(err, initialized) {
expect(initialized).to.have.length(0);
expect(err).to.eql(null);
done();
});
});

it("should initialize webapp extensions routes", function(done) {
var emitter = new EventEmitter();
var config = {};
var urlpaths = [];
var appInstance = {
use: function(path) {
urlpaths.push(path);
},
get: function(p, f) {},
post: function(p, f) {},
delete: function(p, f) {},
put: function(p, f) {},
};
var l = [];
function registerTransportMiddleware(m) {
l.push(m);
}
var context = {
config: config,
emitter: emitter,
extensionRoutes: [],
registerTransportMiddleware: registerTransportMiddleware
};
loader.initWebAppExtensions("./node_modules_ext2", context, appInstance, function(err, initialized) {
expect(l).to.have.length(3);
expect(context.extensionRoutes).to.have.length(1);
expect(context.extensionRoutes[0].path).to.eql('/foo');
expect(context.extensionRoutes[0].method).to.eql('get');
done();
});
});

it("should initialize extensions in order of weight", function(done) {
var emitter = new EventEmitter();
var config = {};
var urlpaths = [];
var appInstance = {
use: function(path) {
urlpaths.push(path);
},
get: function(p, f) {},
post: function(p, f) {},
delete: function(p, f) {},
put: function(p, f) {},
};
var l = [];
function registerTransportMiddleware(m) {
l.push(m);
}
var context = {
config: config,
emitter: emitter,
extensionRoutes: [],
registerTransportMiddleware: registerTransportMiddleware
};
loader.initWebAppExtensions("./node_modules_ext2", context, appInstance, function(err, initialized) {
expect(l).to.have.length(3);
// Verify the static paths are mapped for the two webapp extensions
expect(urlpaths).to.contain("/ext/foobar-strider");
expect(urlpaths).to.contain("/ext/foobar-strider-webapp");
// Verify order
expect(urlpaths[1]).to.eql("/ext/foobar-strider-webapp-routes");
done();
});
});
});

after(function(done) {
Expand All @@ -281,42 +193,3 @@ describe("#Loader", function() {
});



describe("#listWorkerExtensions", function() {

before(function(done) {
mkpath("./node_modules_noext/foobar");
mkpath("./node_modules_noext/foobar2");
mkpath("./node_modules_ext/foobar");
mkpath("./node_modules_ext/foobar-strider");
var strider_json = {
id: "foobar-strider",
webapp: "webapp.js",
worker: "worker.js"
};
fs.writeFileSync("./node_modules_ext/foobar-strider/strider.json", JSON.stringify(strider_json));
mkpath("./node_modules_ext/foobar-strider2");
var strider_json = {
id: "foobar-strider2",
webapp: "webapp.js",
};
fs.writeFileSync("./node_modules_ext/foobar-strider2/strider.json", JSON.stringify(strider_json));
done();
});

it("should get a list", function(done) {
loader.listWorkerExtensions('./node_modules_ext', function(err, loaded){
assert(!err)
assert.equal(loaded.length, 1);
done();
})
})



after(function(done) {
exec("rm -rf node_modules_noext node_modules_ext node_modules_ext2", function() {
done();
});
})
})

0 comments on commit 322769d

Please sign in to comment.