-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jahed Ahmed
committed
Aug 9, 2021
1 parent
755f586
commit bdb640a
Showing
10 changed files
with
24 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
collectCoverage: false, // not collecting coverage for now | ||
collectCoverageFrom: ['src/**/*.ts'], | ||
coverageReporters: ['text-summary', 'html'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 16 additions & 18 deletions
34
packages/snyk-protect/test/unit/explore-node-modules.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,49 @@ | ||
import * as path from 'path'; | ||
import { findPhysicalModules } from '../../src/lib/explore-node-modules'; | ||
|
||
describe(findPhysicalModules.name, () => { | ||
describe('findPhysicalModules', () => { | ||
it('works with no matching physical modules', () => { | ||
const fixtureFolderRelativePath = '../fixtures/no-matching-paths'; | ||
const fixtureFolder = path.join(__dirname, fixtureFolderRelativePath); | ||
const fixtureFolder = path.resolve( | ||
__dirname, | ||
'../fixtures/no-matching-paths', | ||
); | ||
const found = findPhysicalModules(fixtureFolder, ['lodash']); | ||
expect(found).toHaveLength(0); | ||
}); | ||
|
||
it('works with single matching physical module', () => { | ||
const fixtureFolderRelativePath = '../fixtures/single-patchable-module'; | ||
const fixtureFolder = path.join(__dirname, fixtureFolderRelativePath); | ||
const fixtureFolder = path.resolve( | ||
__dirname, | ||
'../fixtures/single-patchable-module', | ||
); | ||
const found = findPhysicalModules(fixtureFolder, ['lodash']); | ||
expect(found).toHaveLength(1); | ||
const m = found[0]; | ||
expect(m.packageName).toBe('lodash'); | ||
expect(m.packageVersion).toBe('4.17.15'); | ||
expect(m.path).toEqual( | ||
path.join( | ||
__dirname, | ||
fixtureFolderRelativePath, | ||
'/node_modules/nyc/node_modules/lodash', | ||
), | ||
path.resolve(fixtureFolder, './node_modules/nyc/node_modules/lodash'), | ||
); | ||
}); | ||
|
||
it('works with multiple matching physical modules', () => { | ||
const fixtureFolderRelativePath = '../fixtures/multiple-matching-paths'; | ||
const fixtureFolder = path.join(__dirname, fixtureFolderRelativePath); | ||
const fixtureFolder = path.resolve( | ||
__dirname, | ||
'../fixtures/multiple-matching-paths', | ||
); | ||
const found = findPhysicalModules(fixtureFolder, ['lodash']); | ||
expect(found).toHaveLength(2); | ||
const m0 = found[0]; | ||
expect(m0.packageName).toBe('lodash'); | ||
expect(m0.packageVersion).toBe('4.17.15'); | ||
expect(m0.path).toEqual( | ||
path.join(__dirname, fixtureFolderRelativePath, '/node_modules/lodash'), | ||
path.resolve(fixtureFolder, './node_modules/lodash'), | ||
); | ||
const m1 = found[1]; | ||
expect(m1.packageName).toBe('lodash'); | ||
expect(m1.packageVersion).toBe('4.17.15'); | ||
expect(m1.path).toEqual( | ||
path.join( | ||
__dirname, | ||
fixtureFolderRelativePath, | ||
'/node_modules/nyc/node_modules/lodash', | ||
), | ||
path.resolve(fixtureFolder, './node_modules/nyc/node_modules/lodash'), | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters