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 committed Apr 3, 2021
1 parent a8c7dfb commit 0af4337
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/extension.js
Expand Up @@ -10,6 +10,7 @@ module.exports = function (input) {
return;
}
var possibleExtensions = longExtension[1].match(EXTRE);
/* istanbul ignore if */
if (!possibleExtensions) {
return;
}
Expand Down
Empty file added test/fixtures/cwd/test.foo
Empty file.
15 changes: 15 additions & 0 deletions test/index.js
Expand Up @@ -269,5 +269,20 @@ describe('rechoir', function () {

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 0af4337

Please sign in to comment.