Skip to content

Commit

Permalink
Test: Add a test case using cwd for prepare.
Browse files Browse the repository at this point in the history
  • Loading branch information
sttk authored and phated committed Jul 24, 2021
1 parent 1150adb commit 6523514
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Empty file added test/fixtures/cwd/test.foo
Empty file.
19 changes: 17 additions & 2 deletions test/index.js
Expand Up @@ -270,7 +270,7 @@ describe('rechoir', function () {
done();
});

it('should register a module loader even if the extension is single character (issue #38)', function(done) {
it('should register a module loader even if the extension is single character (issue #38)', function (done) {
var fpath = path.join(__dirname, 'fixtures', 'test.s');
rechoir.prepare({
'.s': [
Expand All @@ -279,11 +279,26 @@ describe('rechoir', function () {
],
}, fpath);

expect(function() {
expect(function () {
require(fpath);
}).toNotThrow(Error);

done();
});

it('should register a module loader for the specified extension with cwd', function (done) {
rechoir.prepare(
{
'.foo': ['nothere', '../require-stub'],
},
path.join('cwd', 'test.foo'),
path.join(__dirname, 'fixtures')
);
expect(function () {
require(testFilePath);
}).not.toThrow(Error);

done();
});
});
});

0 comments on commit 6523514

Please sign in to comment.