2018-06-22 14:22:32 -05:00
|
|
|
import {DEFAULT_NO_README, HTTP_STATUS} from '../../../src/lib/constants';
|
2017-07-24 16:09:28 -05:00
|
|
|
|
2019-09-26 11:22:14 -05:00
|
|
|
import pkgReadmeJSON from './pkg-readme.json';
|
|
|
|
import pkgNoReadmeJSON from './pkg-no-readme.json';
|
2020-11-28 16:57:52 -05:00
|
|
|
import pkgNoReadmeJSONOldFormat from './pkg-readme-npm6.json';
|
2019-09-26 11:22:14 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
export default function (server, server2) {
|
2017-07-24 16:09:28 -05:00
|
|
|
|
|
|
|
describe('should test readme', () => {
|
2018-06-22 14:22:32 -05:00
|
|
|
const README_PKG1 = 'readme-test';
|
|
|
|
const README_PKG2 = 'readme-test-no-readme';
|
2019-05-17 10:03:58 -05:00
|
|
|
const README_MESSAGE = 'this is a readme';
|
2020-11-28 16:57:52 -05:00
|
|
|
const README_PKG3 = 'readme-test-npm6';
|
2018-06-22 14:22:32 -05:00
|
|
|
|
|
|
|
beforeAll(async function() {
|
2019-09-26 11:22:14 -05:00
|
|
|
await server.putPackage('readme-test', pkgReadmeJSON)
|
2018-06-22 14:22:32 -05:00
|
|
|
.status(HTTP_STATUS.CREATED);
|
2019-09-26 11:22:14 -05:00
|
|
|
await server.putPackage(README_PKG2, pkgNoReadmeJSON)
|
2018-06-22 14:22:32 -05:00
|
|
|
.status(HTTP_STATUS.CREATED);
|
2020-11-28 16:57:52 -05:00
|
|
|
await server.putPackage(README_PKG3, pkgNoReadmeJSONOldFormat)
|
|
|
|
.status(HTTP_STATUS.CREATED);
|
2017-07-24 16:09:28 -05:00
|
|
|
});
|
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('add pkg', () => {});
|
2017-07-24 16:09:28 -05:00
|
|
|
|
|
|
|
describe('should check readme file', () => {
|
2019-05-17 10:03:58 -05:00
|
|
|
const matchReadme = (serverRef, pkgName = README_PKG1, readmeMessage = README_MESSAGE) => {
|
2018-01-27 20:40:07 -05:00
|
|
|
return serverRef.request({
|
2018-06-22 14:22:32 -05:00
|
|
|
uri: `/-/verdaccio/package/readme/${pkgName}`
|
|
|
|
}).status(HTTP_STATUS.OK).then(function(body) {
|
2019-05-17 10:03:58 -05:00
|
|
|
|
|
|
|
expect(body).toEqual(`<p>${readmeMessage}</p>`);
|
2017-07-24 16:09:28 -05:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-06-22 14:22:32 -05:00
|
|
|
test('should fetch server2 over uplink server1', () => {
|
2019-05-17 10:03:58 -05:00
|
|
|
return matchReadme(server, README_PKG1, README_MESSAGE);
|
2018-06-22 14:22:32 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('should fetch package on local server1', () => {
|
2019-05-17 10:03:58 -05:00
|
|
|
return matchReadme(server2, README_PKG1, README_MESSAGE);
|
2017-07-24 16:09:28 -05:00
|
|
|
});
|
|
|
|
|
2018-06-22 14:22:32 -05:00
|
|
|
test('should fetch not found readme server2 over uplink server1', () => {
|
|
|
|
return matchReadme(server, README_PKG2, DEFAULT_NO_README);
|
2017-07-24 16:09:28 -05:00
|
|
|
});
|
|
|
|
|
2020-11-28 16:57:52 -05:00
|
|
|
test('should fetch found readme special case for npm6', () => {
|
|
|
|
return matchReadme(server, README_PKG3, DEFAULT_NO_README);
|
|
|
|
});
|
|
|
|
|
2018-06-22 14:22:32 -05:00
|
|
|
test('should fetch not found readme package on local server1', () => {
|
|
|
|
return matchReadme(server2, README_PKG2, DEFAULT_NO_README);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-07-24 16:09:28 -05:00
|
|
|
});
|
|
|
|
});
|
2017-12-02 05:19:08 -05:00
|
|
|
}
|