2020-06-30 14:55:14 -05:00
|
|
|
import supertest from 'supertest';
|
|
|
|
|
2021-10-29 10:33:05 -05:00
|
|
|
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
|
|
|
|
2022-07-29 13:51:45 -05:00
|
|
|
import { initializeServer, publishVersion } from './_helper';
|
2020-06-30 14:55:14 -05:00
|
|
|
|
|
|
|
describe('package', () => {
|
2020-08-13 16:27:00 -05:00
|
|
|
let app;
|
2020-08-19 13:27:35 -05:00
|
|
|
beforeEach(async () => {
|
2020-08-13 16:27:00 -05:00
|
|
|
app = await initializeServer('package.yaml');
|
|
|
|
});
|
2020-06-30 14:55:14 -05:00
|
|
|
|
2022-07-29 13:51:45 -05:00
|
|
|
test.each([['foo'], ['@scope/foo']])('should return a foo private package', async (pkg) => {
|
|
|
|
await publishVersion(app, pkg, '1.0.0');
|
|
|
|
const response = await supertest(app)
|
|
|
|
.get(`/${pkg}`)
|
|
|
|
.set(HEADERS.ACCEPT, HEADERS.JSON)
|
2020-08-13 16:27:00 -05:00
|
|
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
2022-07-29 13:51:45 -05:00
|
|
|
.expect(HTTP_STATUS.OK);
|
|
|
|
expect(response.body.name).toEqual(pkg);
|
2020-08-13 16:27:00 -05:00
|
|
|
});
|
2020-06-30 14:55:14 -05:00
|
|
|
|
2022-07-29 13:51:45 -05:00
|
|
|
test.each([['foo'], ['@scope/foo']])(
|
|
|
|
'should return a foo private package by version',
|
|
|
|
async (pkg) => {
|
|
|
|
await publishVersion(app, pkg, '1.0.0');
|
|
|
|
const response = await supertest(app)
|
|
|
|
.get(`/${pkg}`)
|
|
|
|
.set(HEADERS.ACCEPT, HEADERS.JSON)
|
|
|
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
|
|
.expect(HTTP_STATUS.OK);
|
|
|
|
expect(response.body.name).toEqual(pkg);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
test.each([['foo'], ['@scope/foo']])(
|
|
|
|
'should return a foo private package by version',
|
|
|
|
async (pkg) => {
|
|
|
|
await publishVersion(app, pkg, '1.0.0');
|
|
|
|
const response = await supertest(app)
|
|
|
|
.get(`/${pkg}`)
|
|
|
|
.set(HEADERS.ACCEPT, HEADERS.JSON)
|
|
|
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
|
|
.expect(HTTP_STATUS.OK);
|
|
|
|
expect(response.body.name).toEqual(pkg);
|
|
|
|
}
|
|
|
|
);
|
2020-06-30 14:55:14 -05:00
|
|
|
});
|