2014-12-15 07:21:28 +08:00
|
|
|
/* jshint expr:true */
|
2014-10-30 06:25:35 +08:00
|
|
|
"use strict";
|
|
|
|
|
2014-12-15 07:21:28 +08:00
|
|
|
var Registry = source("registry");
|
2014-10-30 06:25:35 +08:00
|
|
|
|
2014-12-15 07:21:28 +08:00
|
|
|
var path = "./../spec/support/mock_module.js";
|
2014-10-30 06:25:35 +08:00
|
|
|
|
2014-12-15 07:21:28 +08:00
|
|
|
var module = require("./../support/mock_module.js")
|
2014-10-30 06:25:35 +08:00
|
|
|
|
2014-11-01 05:14:02 +08:00
|
|
|
describe("Registry", function() {
|
2014-10-31 04:15:40 +08:00
|
|
|
var original;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
2014-11-01 05:14:02 +08:00
|
|
|
original = Registry.data;
|
|
|
|
Registry.data = {};
|
2014-10-31 04:15:40 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function() {
|
2014-11-01 05:14:02 +08:00
|
|
|
Registry.data = original;
|
2014-10-31 04:15:40 +08:00
|
|
|
})
|
|
|
|
|
2014-10-30 06:25:35 +08:00
|
|
|
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-10-30 06:25:35 +08:00
|
|
|
|
2014-11-01 05:14:02 +08:00
|
|
|
Registry.register(path);
|
2014-10-30 06:25:35 +08:00
|
|
|
|
2014-11-01 05:14:02 +08:00
|
|
|
expect(Registry.data).to.be.eql({
|
2014-10-30 06:25:35 +08:00
|
|
|
"./../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: []
|
2014-10-30 06:25:35 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#findByAdaptor", function() {
|
|
|
|
beforeEach(function() {
|
2014-11-01 05:14:02 +08:00
|
|
|
Registry.register(path)
|
2014-10-30 06:25:35 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
2014-10-30 06:25:35 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#findByDriver", function() {
|
|
|
|
beforeEach(function() {
|
2014-11-01 05:14:02 +08:00
|
|
|
Registry.register(path)
|
2014-10-30 06:25:35 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
2014-10-30 06:25:35 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|