mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
chore: organize block unit test
add some extra context
This commit is contained in:
parent
71a0a43343
commit
7aef6d8a59
2 changed files with 44 additions and 33 deletions
|
@ -3,7 +3,7 @@
|
|||
"files": null,
|
||||
"lines": null
|
||||
},
|
||||
"generated_at": "2019-07-19T05:01:56Z",
|
||||
"generated_at": "2019-07-27T05:16:42Z",
|
||||
"plugins_used": [
|
||||
{
|
||||
"name": "AWSKeyDetector"
|
||||
|
@ -270,12 +270,12 @@
|
|||
"test/unit/modules/api/api.spec.ts": [
|
||||
{
|
||||
"hashed_secret": "97752a468368b0d6b192140d6a140c38fd0cbd8b",
|
||||
"line_number": 287,
|
||||
"line_number": 292,
|
||||
"type": "Secret Keyword"
|
||||
},
|
||||
{
|
||||
"hashed_secret": "364bdf2ed77a8544d3b711a03b69eeadcc63c9d7",
|
||||
"line_number": 786,
|
||||
"line_number": 799,
|
||||
"type": "Secret Keyword"
|
||||
}
|
||||
],
|
||||
|
@ -2985,5 +2985,5 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"version": "0.12.2"
|
||||
"version": "0.12.4"
|
||||
}
|
||||
|
|
|
@ -56,7 +56,10 @@ describe('endpoint unit test', () => {
|
|||
npmjs: {
|
||||
url: `http://${DOMAIN_SERVERS}:${mockServerPort}`
|
||||
}
|
||||
}
|
||||
},
|
||||
logs: [
|
||||
{ type: 'stdout', format: 'pretty', level: 'warn' }
|
||||
]
|
||||
}, 'api.spec.yaml');
|
||||
|
||||
app = await endPointAPI(configForTest);
|
||||
|
@ -307,6 +310,12 @@ describe('endpoint unit test', () => {
|
|||
});
|
||||
|
||||
describe('should test package api', () => {
|
||||
// The current behaviour depends of what's defined in the following configuration file.
|
||||
// test/unit/partials/config/yaml/api.spec.yaml
|
||||
// 'jquery':
|
||||
// access: $all
|
||||
// publish: $all
|
||||
// proxy: npmjs
|
||||
|
||||
test('should fetch jquery package from remote uplink', (done) => {
|
||||
|
||||
|
@ -392,35 +401,37 @@ describe('endpoint unit test', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('be able to filter packages', (done) => {
|
||||
request(app)
|
||||
.get('/npm_test')
|
||||
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
||||
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
||||
.expect(HTTP_STATUS.OK)
|
||||
.end(function(err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
// Filter out 2.0.0
|
||||
expect(Object.keys(res.body.versions)).toEqual(['1.0.0']);
|
||||
done();
|
||||
});
|
||||
});
|
||||
describe('testing filters', () => {
|
||||
test('be able to filter packages', (done) => {
|
||||
request(app)
|
||||
.get('/npm_test')
|
||||
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
||||
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
||||
.expect(HTTP_STATUS.OK)
|
||||
.end(function(err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
// Filter out 2.0.0
|
||||
expect(Object.keys(res.body.versions)).toEqual(['1.0.0']);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('should not found when a filter fails', (done) => {
|
||||
request(app)
|
||||
// Filter errors look like other uplink errors
|
||||
.get('/trigger-filter-failure')
|
||||
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
||||
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
||||
.expect(HTTP_STATUS.NOT_FOUND)
|
||||
.end(function(err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
done();
|
||||
});
|
||||
test('should not found when a filter fails', (done) => {
|
||||
request(app)
|
||||
// Filter errors look like other uplink errors
|
||||
.get('/trigger-filter-failure')
|
||||
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
||||
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
||||
.expect(HTTP_STATUS.NOT_FOUND)
|
||||
.end(function(err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('should forbid access to remote package', (done) => {
|
||||
|
|
Loading…
Reference in a new issue