Commit 14d31e4f authored by Tom Jorquera's avatar Tom Jorquera

lib: renamed `lib/controller` to `lib/loader`

Server-side module `controller` used a confusing name not actually reflecting
its purpose. Rename it to the more accurate `loader` name.
parent 51696e42
......@@ -21,13 +21,13 @@
const config = require('./config.json');
const runner = require('./lib/runner.js')(config.runner);
const controller = require('./lib/controller.js')('./client');
const loader = require('./lib/loader.js')('./client');
const registry = {};
console.log('starting hublot...');
controller.loadAll('controller', 'lib', 'robot')
loader.loadAll('controller', 'lib', 'robot')
.then(modules => {
console.log('modules loaded... launching runner');
......
......@@ -39,9 +39,9 @@ describe('loadModules', () => {
describe('loading a module', () => {
test('should include all (and only) non-test files in its dir.', done => {
const controller = require('./controller.js')('/test');
const loader = require('./loader.js')('/test');
controller.load('controller')
loader.load('controller')
.then(res => {
expect(res.length).toBe(2);
expect(res.includes('1')).toBeTruthy();
......@@ -51,9 +51,9 @@ describe('loadModules', () => {
});
test('should return the files in the correct order', done => {
const controller = require('./controller.js')('/test');
const loader = require('./loader.js')('/test');
controller.load('controller')
loader.load('controller')
.then(res => {
expect(res[0]).toBe('1');
expect(res[1]).toBe('2');
......@@ -62,25 +62,25 @@ describe('loadModules', () => {
});
test('should fail for a nonexistent module', done => {
const controller = require('./controller.js')('/test');
const loader = require('./loader.js')('/test');
controller.load('nonexistent')
loader.load('nonexistent')
.catch(() => done());
});
test('should fail for a module missing its base file', done => {
const controller = require('./controller.js')('/test');
const loader = require('./loader.js')('/test');
controller.load('notavalidmodule')
loader.load('notavalidmodule')
.catch(() => done());
});
});
describe('loading several modules', () => {
test('should include all files from all modules', done => {
const controller = require('./controller.js')('/test');
const loader = require('./loader.js')('/test');
controller.loadAll('controller', 'lib', 'robot')
loader.loadAll('controller', 'lib', 'robot')
.then(res => {
expect(res.length).toBe(4);
expect(res.includes('1')).toBeTruthy();
......@@ -92,9 +92,9 @@ describe('loadModules', () => {
});
test('should return files in correct order', done => {
const controller = require('./controller.js')('/test');
const loader = require('./loader.js')('/test');
controller.loadAll('controller', 'lib', 'robot')
loader.loadAll('controller', 'lib', 'robot')
.then(res => {
expect(res[0]).toBe('1');
expect(res[1]).toBe('2');
......@@ -105,14 +105,14 @@ describe('loadModules', () => {
});
test('should fail when trying to load a non-existent module ', done => {
const controller = require('./controller.js')('/test');
controller.loadAll('controller', 'lib', 'robot', 'nonexistent')
const loader = require('./loader.js')('/test');
loader.loadAll('controller', 'lib', 'robot', 'nonexistent')
.catch(() => done());
});
test('should fail when trying to load an invalid module', done => {
const controller = require('./controller.js')('/test');
controller.loadAll('controller', 'lib', 'robot', 'invalid')
const loader = require('./loader.js')('/test');
loader.loadAll('controller', 'lib', 'robot', 'invalid')
.catch(() => done());
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment