-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Due to my env issue, I implemented it in a wrong way, this fixes it. More detail: nodejs/node#1488
- Loading branch information
Showing
8 changed files
with
87 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var expect = require('chai').expect | ||
var path = require('path') | ||
|
||
require('../../register.js') | ||
|
||
describe('requere/register', function () { | ||
it('should require module correctly', function () { | ||
var _path = require('path') | ||
expect(path).to.equal(_path) | ||
}) | ||
|
||
it('should resolve module start from module root', function () { | ||
var res = require('test/textual/nested/nested') | ||
|
||
expect(res).to.be.equal('foo.js in nested folders') | ||
}) | ||
|
||
it('should work with transipler', function () { | ||
require('coffee-script/register') | ||
|
||
var b = require('test/textual/b.coffee') | ||
expect(b()).to.equal('Module B') | ||
}) | ||
|
||
it('should throw exception if module cannot found', function () { | ||
var func = function () { | ||
require('module_not_found') | ||
} | ||
expect(func).to.throw('Cannot find module \'module_not_found\'') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var expect = require('chai').expect | ||
var requere = require('../../index.js') | ||
|
||
describe('requere()', function () { | ||
it('should be a function', function () { | ||
expect(requere).to.be.a('function') | ||
}) | ||
|
||
it('should require module correctly', function () { | ||
var path = requere('path') | ||
expect(path).to.equal(require('path')) | ||
expect(require('../textual/a.js')).to.equal(requere('test/textual/a.js')) | ||
}) | ||
|
||
it('should resolve module start from module root', function () { | ||
var res1 = requere('test/textual/nested/nested') | ||
var res2 = require('../../test/textual/nested/nested.js') | ||
|
||
expect(res1).to.be.equal(res2) | ||
}) | ||
|
||
it('should work with transipler', function () { | ||
require('coffee-script/register') | ||
|
||
var b = requere('test/textual/b.coffee') | ||
expect(b()).to.equal('Module B') | ||
}) | ||
|
||
it('should throw exception if module cannot found', function () { | ||
var func = function () { | ||
requere('module_not_found') | ||
} | ||
expect(func).to.throw('Cannot find module \'module_not_found\'') | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
module.exports = require('test/textual/nested/foo.js') | ||
var requere = require('../../../index.js') | ||
module.exports = requere('test/textual/nested/foo.js') |