it('handles bad path', function () { const name = 'some name'; lib.getComponentPath.returns(null); expect(fn(name)).to.equal(null); });
it('eats "Cannot find module" errors', function () { const name = 'some name', path = 'some path'; req.throws(new Error('Cannot find module')); lib.getComponentPath.returns(path); expect(fn(name)).to.equal(undefined); });
it('throw normal errors from require', function () { const name = 'some name', path = 'some path'; req.throws(new Error('some error')); lib.getComponentPath.returns(path); expect(function () { fn(name); }).to.throw(); });
it('handles index.js path', function () { const name = 'some name', path = 'some path', result = []; lib.getComponentPath.returns(path); req.withArgs(path + '/package.json').returns(result); expect(fn(name)).to.equal(result); });
it('handles server.js path', function () { const name = 'some name', path = 'some path', result = 'some result'; lib.getComponentPath.returns(path); req.withArgs(path + '/server').returns(result); expect(fn(name)).to.equal(result); });