Skip to content

Commit

Permalink
Merge pull request #1 from Annosha/anu-local-module
Browse files Browse the repository at this point in the history
Added local test pkg
  • Loading branch information
Annosha authored Oct 16, 2024
2 parents 4947c2d + 9871639 commit c395222
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ describe('RequireInTheMiddleSingleton', () => {
const onRequireFsPromisesStub = makeOnRequiresStub('fs-promises');
const onRequireCodecovStub = makeOnRequiresStub('codecov');
const onRequireCodecovLibStub = makeOnRequiresStub('codecov-lib');
const onRequireCpxStub = makeOnRequiresStub('cpx2');
const onRequireCpxLibStub = makeOnRequiresStub('cpx2-lib');
const onRequireCpxStub = makeOnRequiresStub('test-non-core-module');
const onRequireCpxLibStub = makeOnRequiresStub('test-non-core-module-lib');

before(() => {
requireInTheMiddleSingleton.register('fs', onRequireFsStub);
Expand All @@ -53,9 +53,9 @@ describe('RequireInTheMiddleSingleton', () => {
'codecov/lib/codecov.js',
onRequireCodecovLibStub
);
requireInTheMiddleSingleton.register('cpx2', onRequireCpxStub);
requireInTheMiddleSingleton.register('test-non-core-module', onRequireCpxStub);
requireInTheMiddleSingleton.register(
'cpx2/lib/copy-sync.js',
'test-non-core-module/lib/copy-sync.js',
onRequireCpxLibStub
);
});
Expand Down Expand Up @@ -120,8 +120,8 @@ describe('RequireInTheMiddleSingleton', () => {

describe('non-core module', () => {
describe('AND module name matches', () => {
const baseDir = path.dirname(require.resolve('codecov'));
const modulePath = path.join('codecov', 'lib', 'codecov.js');
const baseDir = path.normalize(path.dirname(require.resolve('codecov')));
const modulePath = path.normalize(path.join('codecov', 'lib', 'codecov.js'));
it('should call `onRequire`', () => {
const exports = require('codecov');
assert.deepStrictEqual(exports.__ritmOnRequires, ['codecov']);
Expand Down Expand Up @@ -149,20 +149,20 @@ describe('RequireInTheMiddleSingleton', () => {

describe('non-core module with sub-path', () => {
describe('AND module name matches', () => {
const baseDir = path.resolve(
path.dirname(require.resolve('cpx2')),
const baseDir = path.normalize(path.resolve(
path.dirname(require.resolve('test-non-core-module')),
'..'
);
const modulePath = path.join('cpx2', 'lib', 'copy-sync.js');
));
const modulePath = path.normalize(path.join('test-non-core-module', 'lib', 'copy-sync.js'));
it('should call `onRequire`', () => {
const exports = require('cpx2/lib/copy-sync');
const exports = require('test-non-core-module/lib/copy-sync');
assert.deepStrictEqual(exports.__ritmOnRequires, [
'cpx2',
'cpx2-lib',
'test-non-core-module',
'test-non-core-module-lib',
]);
sinon.assert.calledWithMatch(
onRequireCpxStub,
{ __ritmOnRequires: ['cpx2', 'cpx2-lib'] },
{ __ritmOnRequires: ['test-non-core-module', 'test-non-core-module-lib'] },
modulePath,
baseDir
);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c395222

Please sign in to comment.