Skip to content

Commit

Permalink
Added exports property to the context
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanmacinnes committed Apr 11, 2014
1 parent 2dcf2fa commit cf551cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/injectr.js
Expand Up @@ -29,6 +29,7 @@ module.exports = function (file, mocks, context) {
};
context.module = context.module || {};
context.module.exports = {};
context.exports = context.module.exports;

script.runInNewContext(context);
return context.module.exports;
Expand Down
8 changes: 8 additions & 0 deletions test/spec.js
Expand Up @@ -91,6 +91,14 @@ describe("injectr", function () {
expect(context.module).to.have.property('exports');
expect(context.module.exports).to.be.an('object');
});
it("should have an exports property equal to module.exports", function () {
var context,
mockScript;
this.injectr('filename');
mockScript = this.mockVm.createScript.calls[0].pretendr;
context = mockScript.runInNewContext.calls[0].args[0];
expect(context).to.have.property('exports', context.module.exports);
});
it("should return module.exports", function () {
var context,
mockScript,
Expand Down

0 comments on commit cf551cb

Please sign in to comment.