2017-09-25 20:11:27 +08:00
|
|
|
function requireInContext(someVariable) {
|
|
|
|
|
return require(`./some-dir/${someVariable}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it("should not exclude paths not matching the exclusion pattern", function() {
|
|
|
|
|
requireInContext("file").should.be.eql("thats good");
|
|
|
|
|
requireInContext("check-here/file").should.be.eql("thats good");
|
|
|
|
|
requireInContext("check-here/check-here/file").should.be.eql("thats good");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should exclude paths/files matching the exclusion pattern", function() {
|
|
|
|
|
(() => requireInContext("dont")).
|
2017-12-19 22:50:09 +08:00
|
|
|
should.throw(/Cannot find module ".\/dont"/);
|
2017-09-25 20:11:27 +08:00
|
|
|
|
|
|
|
|
(() => requireInContext("dont-check-here/file")).
|
2017-12-19 22:50:09 +08:00
|
|
|
should.throw(/Cannot find module ".\/dont-check-here\/file"/);
|
2017-09-25 20:11:27 +08:00
|
|
|
|
|
|
|
|
(() => requireInContext("check-here/dont-check-here/file")).
|
2017-12-19 22:50:09 +08:00
|
|
|
should.throw(/Cannot find module ".\/check-here\/dont-check-here\/file"/);
|
2017-09-25 20:11:27 +08:00
|
|
|
});
|