1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-17 07:45:52 +01:00
verdaccio/test/functional/readme
Juan Picado 93468211d6
chore: update eslint dependencies (#2126)
* chore: update eslint

* chore: update rules and style

* chore: aling formatting

* chore: update ci rules

* chore: aling formatting

* chore: aling formatting
2021-03-14 08:42:46 +01:00
..
pkg-no-readme.json refactor: get rid of personal emails 2018-06-23 20:59:34 +02:00
pkg-readme-npm6.json fix: fix missing readme on npm7 (#2010) 2020-11-28 22:57:52 +01:00
pkg-readme.json fix: fix missing readme on npm7 (#2010) 2020-11-28 22:57:52 +01:00
readme.ts chore: update eslint dependencies (#2126) 2021-03-14 08:42:46 +01:00

import { DEFAULT_NO_README, HTTP_STATUS } from '../../../src/lib/constants';

import pkgReadmeJSON from './pkg-readme.json';
import pkgNoReadmeJSON from './pkg-no-readme.json';
import pkgNoReadmeJSONOldFormat from './pkg-readme-npm6.json';

export default function (server, server2) {
  describe('should test readme', () => {
    const README_PKG1 = 'readme-test';
    const README_PKG2 = 'readme-test-no-readme';
    const README_MESSAGE = 'this is a readme';
    const README_PKG3 = 'readme-test-npm6';

    beforeAll(async function () {
      await server.putPackage('readme-test', pkgReadmeJSON).status(HTTP_STATUS.CREATED);
      await server.putPackage(README_PKG2, pkgNoReadmeJSON).status(HTTP_STATUS.CREATED);
      await server.putPackage(README_PKG3, pkgNoReadmeJSONOldFormat).status(HTTP_STATUS.CREATED);
    });

    test('add pkg', () => {});

    describe('should check readme file', () => {
      const matchReadme = (serverRef, pkgName = README_PKG1, readmeMessage = README_MESSAGE) => {
        return serverRef
          .request({
            uri: `/-/verdaccio/package/readme/${pkgName}`
          })
          .status(HTTP_STATUS.OK)
          .then(function (body) {
            expect(body).toEqual(`<p>${readmeMessage}</p>`);
          });
      };

      test('should fetch server2 over uplink server1', () => {
        return matchReadme(server, README_PKG1, README_MESSAGE);
      });

      test('should fetch package on local server1', () => {
        return matchReadme(server2, README_PKG1, README_MESSAGE);
      });

      test('should fetch not found readme server2 over uplink server1', () => {
        return matchReadme(server, README_PKG2, DEFAULT_NO_README);
      });

      test('should fetch found readme special case for npm6', () => {
        return matchReadme(server, README_PKG3, DEFAULT_NO_README);
      });

      test('should fetch not found readme package on local server1', () => {
        return matchReadme(server2, README_PKG2, DEFAULT_NO_README);
      });
    });
  });
}