cylon/spec/lib/registry.spec.js

59 lines
1.3 KiB
JavaScript

/* jshint expr:true */
"use strict";
var Registry = source("registry");
var path = "./../spec/support/mock_module.js";
var mod = require("./../support/mock_module.js");
describe("Registry", function() {
var original;
beforeEach(function() {
original = Registry.data;
Registry.data = {};
});
afterEach(function() {
Registry.data = original;
});
describe("#register", function() {
it("adds the supplied module to the Registry", function() {
expect(Registry.data).to.be.eql({});
Registry.register(path);
expect(Registry.data).to.be.eql({
"./../spec/support/mock_module.js": {
module: mod,
drivers: ["test-driver"],
adaptors: ["test-adaptor"],
dependencies: []
}
});
});
});
describe("#findByAdaptor", function() {
beforeEach(function() {
Registry.register(path);
});
it("finds the appropriate module containing the adaptor", function() {
expect(Registry.findByAdaptor("test-adaptor")).to.be.eql(mod);
});
});
describe("#findByDriver", function() {
beforeEach(function() {
Registry.register(path);
});
it("finds the appropriate module containing the driver", function() {
expect(Registry.findByDriver("test-driver")).to.be.eql(mod);
});
});
});