-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create test for dependency-discovery service
- Loading branch information
1 parent
e720097
commit b6967fb
Showing
6 changed files
with
42 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const baseConfig = require('../../../jest.config.base'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
setupFiles: ['<rootDir>/src/api/dependency-discovery/jest.setup.js'], | ||
rootDir: '../../..', | ||
testMatch: ['<rootDir>/src/api/dependency-discovery/test/*.test.js'], | ||
collectCoverageFrom: ['<rootDir>/src.api/dependency-discovery/src/**/*.js'], | ||
}; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
process.env = { ...process.env }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const request = require('supertest'); | ||
const { app } = require('../src'); | ||
|
||
const depsList = [ | ||
'@apidevtools/json-schema-ref-parser', | ||
'@babel/code-frame', | ||
'@babel/compat-data', | ||
'@babel/core", "@babel/generator', | ||
'@babel/helper-annotate-as-pure', | ||
'@babel/helper-builder-binary-assignment-operator-visitor', | ||
'@babel/helper-compilation-targets', | ||
'@babel/helper-create-class-features-plugin', | ||
'@babel/helper-create-regexp-features-plugin', | ||
]; | ||
|
||
jest.mock('../src/dependency-list', () => { | ||
return jest.fn().mockImplementation(() => { | ||
return Promise.resolve(depsList); | ||
}); | ||
}); | ||
|
||
describe('GET /projects', () => { | ||
test('Should return 200 and an array of dependencies', async () => { | ||
const res = await request(app).get('/projects'); | ||
expect(res.status).toBe(200); | ||
expect(typeof res.body).toEqual('object'); | ||
expect(res.body.length).toBe(depsList.length); | ||
}); | ||
}); |