2018-06-22 21:22:32 +02:00
|
|
|
import {DEFAULT_NO_README, HTTP_STATUS} from '../../../src/lib/constants';
|
2017-07-24 23:09:28 +02:00
|
|
|
|
2017-12-02 11:19:08 +01:00
|
|
|
export default function (server, server2) {
|
2017-07-24 23:09:28 +02:00
|
|
|
|
|
|
|
describe('should test readme', () => {
|
2018-06-22 21:22:32 +02:00
|
|
|
const README_PKG1 = 'readme-test';
|
|
|
|
const README_PKG2 = 'readme-test-no-readme';
|
|
|
|
|
|
|
|
beforeAll(async function() {
|
|
|
|
await server.putPackage('readme-test', require('./pkg-readme.json'))
|
|
|
|
.status(HTTP_STATUS.CREATED);
|
|
|
|
await server.putPackage(README_PKG2, require('./pkg-no-readme.json'))
|
|
|
|
.status(HTTP_STATUS.CREATED);
|
2017-07-24 23:09:28 +02:00
|
|
|
});
|
|
|
|
|
2017-12-02 11:19:08 +01:00
|
|
|
test('add pkg', () => {});
|
2017-07-24 23:09:28 +02:00
|
|
|
|
|
|
|
describe('should check readme file', () => {
|
2018-06-22 21:22:32 +02:00
|
|
|
const matchReadme = (serverRef, pkgName = README_PKG1, readmeMessage = 'this is a readme') => {
|
2018-01-28 02:40:07 +01:00
|
|
|
return serverRef.request({
|
2018-06-22 21:22:32 +02:00
|
|
|
uri: `/-/verdaccio/package/readme/${pkgName}`
|
|
|
|
}).status(HTTP_STATUS.OK).then(function(body) {
|
|
|
|
expect(body).toEqual(`<p>${readmeMessage}</p>\n`);
|
2017-07-24 23:09:28 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-06-22 21:22:32 +02:00
|
|
|
test('should fetch server2 over uplink server1', () => {
|
|
|
|
return matchReadme(server, README_PKG1, 'this is a readme');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should fetch package on local server1', () => {
|
|
|
|
return matchReadme(server2, README_PKG1, 'this is a readme');
|
2017-07-24 23:09:28 +02:00
|
|
|
});
|
|
|
|
|
2018-06-22 21:22:32 +02:00
|
|
|
test('should fetch not found readme server2 over uplink server1', () => {
|
|
|
|
return matchReadme(server, README_PKG2, DEFAULT_NO_README);
|
2017-07-24 23:09:28 +02:00
|
|
|
});
|
|
|
|
|
2018-06-22 21:22:32 +02:00
|
|
|
test('should fetch not found readme package on local server1', () => {
|
|
|
|
return matchReadme(server2, README_PKG2, DEFAULT_NO_README);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-07-24 23:09:28 +02:00
|
|
|
});
|
|
|
|
});
|
2017-12-02 11:19:08 +01:00
|
|
|
}
|