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

26 lines
744 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$/);
2018-01-27 23:55:38 +08:00
expect(typeof c.id === "number" || typeof c.id === "string").toBeTruthy();
expect(function() {
2014-10-12 17:24:42 +08:00
c.resolve("");
}).toThrowError();
expect(function() {
2014-10-12 17:24:42 +08:00
c("");
}).toThrowError();
expect(c.keys()).toEqual([]);
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();
expect(c.keys()).toEqual([]);
2014-11-02 19:16:55 +08:00
});*/