diff --git a/__tests__/modules/a.js b/__tests__/modules/a.js index 40d53ae..84e5772 100644 --- a/__tests__/modules/a.js +++ b/__tests__/modules/a.js @@ -2,4 +2,7 @@ module.exports = { a() { return 'a - original'; }, + require() { + return 'require method in a.js'; + }, }; diff --git a/__tests__/modules/amd.js b/__tests__/modules/amd.js index 4078dd7..b3aaa7a 100644 --- a/__tests__/modules/amd.js +++ b/__tests__/modules/amd.js @@ -10,5 +10,9 @@ define((require) => { // eslint-disable-line no-undef getB() { return b(); }, + + callRequireMethod() { + return a.require(); + }, }; }); diff --git a/__tests__/modules/commonjs.js b/__tests__/modules/commonjs.js index e6c3a68..98e0ba9 100644 --- a/__tests__/modules/commonjs.js +++ b/__tests__/modules/commonjs.js @@ -9,4 +9,8 @@ module.exports = { getB() { return b(); }, + + callRequireMethod() { + return a.require(); + }, }; diff --git a/__tests__/modules/es6.js b/__tests__/modules/es6.js index ac0e70e..73f60fb 100644 --- a/__tests__/modules/es6.js +++ b/__tests__/modules/es6.js @@ -1,10 +1,14 @@ -import { a } from './a.js'; +import a, { a as methodA } from './a.js'; import b from './b.js'; export function getA() { - return a(); + return methodA(); } export function getB() { return b(); } + +export function callRequireMethod() { + return a.require(); +} diff --git a/__tests__/tests.js b/__tests__/tests.js index db3c35f..cbf5a63 100644 --- a/__tests__/tests.js +++ b/__tests__/tests.js @@ -55,6 +55,12 @@ describe('injectify-loader', () => { assert.throws(injectInvalidDependencies, /The following injections are invalid:\n- \.\/c\.js/); }); + + it('does not break someObject.require calls', () => { + const module = injector.moduleInjector(); + + assert.equal(module.callRequireMethod(), 'require method in a.js'); + }); }); }); }); diff --git a/src/wrapper_template.js b/src/wrapper_template.js index 05afb92..aaec973 100644 --- a/src/wrapper_template.js +++ b/src/wrapper_template.js @@ -19,7 +19,7 @@ export default template(` throw new Error('Some of the injections you passed in are invalid.\\n' + 'Valid injection targets for this module are:\\n' + validDependenciesString + '\\n' + 'The following injections were passed in:\\n' + injectedDependenciesString + '\\n' + - 'The following injections are invalid:\\n' + invalidDependenciesString + 'The following injections are invalid:\\n' + invalidDependenciesString + '\\n' ); } })();