Commit 1b7a292f authored by Tom Jorquera's avatar Tom Jorquera
Browse files

lib/controller: ignore test files

`lib/controller` now ignore test files. Not ignoring test files would means that
the runner would try to load them into the client resulting in errors.

Update tests to check this behavior.

Fixes #12.
parent f90399fa
...@@ -14,6 +14,9 @@ module.exports = root => { ...@@ -14,6 +14,9 @@ module.exports = root => {
// Remove the file we already read // Remove the file we already read
files.splice(files.indexOf(module + '.js'), 1); files.splice(files.indexOf(module + '.js'), 1);
// Ignore test files
files = files.filter(filename => !filename.endsWith('.test.js'));
Promise.all(files.map( Promise.all(files.map(
f => fs.readFile(root + '/' + module + '/' + f, 'utf8') f => fs.readFile(root + '/' + module + '/' + f, 'utf8')
)) ))
......
...@@ -5,10 +5,12 @@ jest.mock('mz/fs'); ...@@ -5,10 +5,12 @@ jest.mock('mz/fs');
describe('loadModules', () => { describe('loadModules', () => {
const MOCK_FILES = { const MOCK_FILES = {
'/test/controller/controller.js': '1', '/test/controller/controller.js': '1',
'/test/controller/test.js': '2', '/test/controller/controller.test.js': 'sometest',
'/test/controller/file.js': '2',
'/test/controller/file.test.js': 'sometest',
'/test/lib/lib.js': '3', '/test/lib/lib.js': '3',
'/test/robot/robot.js': '4', '/test/robot/robot.js': '4',
'/test/notavalidmodule/test.js': '5' '/test/notavalidmodule/file.js': '5'
}; };
beforeEach(() => { beforeEach(() => {
...@@ -16,7 +18,7 @@ describe('loadModules', () => { ...@@ -16,7 +18,7 @@ describe('loadModules', () => {
}); });
describe('loading a module', () => { describe('loading a module', () => {
test('should include all (and only) files in its dir.', done => { test('should include all (and only) non-test files in its dir.', done => {
const controller = require('./controller.js')('/test'); const controller = require('./controller.js')('/test');
controller.load('controller') controller.load('controller')
......
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