webpack/test/cases/context/issue-524/index.js

26 lines
706 B
JavaScript
Raw Normal View History

2014-10-12 17:24:42 +08:00
it("should support an empty context", function() {
var c = require.context(".", true, /^nothing$/);
2016-12-14 19:03:24 +08:00
(typeof c.id).should.be.oneOf(["number", "string"]);
2014-10-12 17:24:42 +08:00
(function() {
c.resolve("");
}).should.throw();
(function() {
c("");
}).should.throw();
c.keys().should.be.eql([]);
2014-11-02 19:16:55 +08:00
});
// This would be a useful testcase, but it requires an (really) empty directory.
// **but** you cannot commit empty directories into git
/*it("should support an empty context (empty dir)", function() {
var c = require.context("./empty", true, /^nothing$/);
c.id.should.be.type("number");
(function() {
c.resolve("");
}).should.throw();
(function() {
c("");
}).should.throw();
c.keys().should.be.eql([]);
});*/