2014-10-12 17:24:42 +08:00
|
|
|
it("should support an empty context", function() {
|
|
|
|
|
var c = require.context(".", true, /^nothing$/);
|
2018-01-27 06:59:38 +08:00
|
|
|
expect(typeof c.id).to.be.oneOf(["number", "string"]);
|
|
|
|
|
expect(function() {
|
2014-10-12 17:24:42 +08:00
|
|
|
c.resolve("");
|
2018-01-27 06:59:38 +08:00
|
|
|
}).toThrowError();
|
|
|
|
|
expect(function() {
|
2014-10-12 17:24:42 +08:00
|
|
|
c("");
|
2018-01-27 06:59:38 +08:00
|
|
|
}).toThrowError();
|
2018-01-27 05:51:03 +08:00
|
|
|
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();
|
2018-01-27 05:51:03 +08:00
|
|
|
expect(c.keys()).toEqual([]);
|
2014-11-02 19:16:55 +08:00
|
|
|
});*/
|