Example #1
0
    it('handles bad path', function () {
      const name = 'some name';

      lib.getComponentPath.returns(null);

      expect(fn(name)).to.equal(null);
    });
Example #2
0
    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);
    });
Example #3
0
    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();
    });
Example #4
0
    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);
    });
Example #5
0
    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);
    });