cylon/spec/lib/registry.spec.js

59 lines
1.3 KiB
JavaScript
Raw Normal View History

2014-12-15 07:21:28 +08:00
/* jshint expr:true */
"use strict";
2014-12-15 07:21:28 +08:00
var Registry = source("registry");
2014-12-15 07:21:28 +08:00
var path = "./../spec/support/mock_module.js";
2014-12-15 07:21:28 +08:00
var module = require("./../support/mock_module.js")
2014-11-01 05:14:02 +08:00
describe("Registry", function() {
var original;
beforeEach(function() {
2014-11-01 05:14:02 +08:00
original = Registry.data;
Registry.data = {};
});
afterEach(function() {
2014-11-01 05:14:02 +08:00
Registry.data = original;
})
describe("#register", function() {
it("adds the supplied module to the Registry", function() {
2014-11-01 05:14:02 +08:00
expect(Registry.data).to.be.eql({});
2014-11-01 05:14:02 +08:00
Registry.register(path);
2014-11-01 05:14:02 +08:00
expect(Registry.data).to.be.eql({
"./../spec/support/mock_module.js": {
module: module,
2014-12-15 07:21:28 +08:00
drivers: ["test-driver"],
adaptors: ["test-adaptor"],
2014-11-06 06:24:07 +08:00
dependencies: []
}
});
});
});
describe("#findByAdaptor", function() {
beforeEach(function() {
2014-11-01 05:14:02 +08:00
Registry.register(path)
});
it("finds the appropriate module containing the adaptor", function() {
2014-12-15 07:21:28 +08:00
expect(Registry.findByAdaptor("test-adaptor")).to.be.eql(module);
});
});
describe("#findByDriver", function() {
beforeEach(function() {
2014-11-01 05:14:02 +08:00
Registry.register(path)
});
it("finds the appropriate module containing the driver", function() {
2014-12-15 07:21:28 +08:00
expect(Registry.findByDriver("test-driver")).to.be.eql(module);
});
});
});