2021-03-06 18:56:45 +01:00
|
|
|
import path from 'path';
|
|
|
|
import supertest from 'supertest';
|
2021-10-29 17:33:05 +02:00
|
|
|
|
|
|
|
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
2021-03-06 18:56:45 +01:00
|
|
|
import { setup } from '@verdaccio/logger';
|
2022-03-27 21:42:52 +02:00
|
|
|
import { publishVersion } from '@verdaccio/test-helper';
|
2021-03-06 18:56:45 +01:00
|
|
|
|
|
|
|
import { initializeServer } from './helper';
|
|
|
|
|
|
|
|
setup([]);
|
|
|
|
|
|
|
|
const mockManifest = jest.fn();
|
|
|
|
jest.mock('@verdaccio/ui-theme', () => mockManifest());
|
|
|
|
|
2022-03-27 21:42:52 +02:00
|
|
|
describe('sidebar api', () => {
|
2021-03-06 18:56:45 +01:00
|
|
|
beforeAll(() => {
|
2022-03-27 21:42:52 +02:00
|
|
|
mockManifest.mockReturnValue(() => ({
|
2021-03-06 18:56:45 +01:00
|
|
|
staticPath: path.join(__dirname, 'static'),
|
2022-03-27 21:42:52 +02:00
|
|
|
manifestFiles: {
|
|
|
|
js: ['runtime.js', 'vendors.js', 'main.js'],
|
|
|
|
},
|
2021-03-06 18:56:45 +01:00
|
|
|
manifest: require('./partials/manifest/manifest.json'),
|
2022-03-27 21:42:52 +02:00
|
|
|
}));
|
2021-03-06 18:56:45 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
jest.clearAllMocks();
|
|
|
|
mockManifest.mockClear();
|
|
|
|
});
|
|
|
|
|
2022-03-27 21:42:52 +02:00
|
|
|
test('should display sidebar info scoped package', async () => {
|
|
|
|
const app = await initializeServer('default-test.yaml');
|
|
|
|
await publishVersion(app, '@scope/pk1-test', '1.0.0', { readme: 'my readme scoped' });
|
|
|
|
const response = await supertest(app)
|
2022-01-15 20:12:28 +01:00
|
|
|
.get('/-/verdaccio/data/sidebar/@scope/pk1-test')
|
2021-03-06 18:56:45 +01:00
|
|
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
|
|
.expect(HTTP_STATUS.OK);
|
2022-03-27 21:42:52 +02:00
|
|
|
expect(response.text).toMatch('@scope/pk1-test');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should display sidebar info package', async () => {
|
|
|
|
const app = await initializeServer('default-test.yaml');
|
|
|
|
await publishVersion(app, 'pk2-test', '1.0.0', { readme: 'my readme scoped' });
|
|
|
|
const response = await supertest(app)
|
|
|
|
.get('/-/verdaccio/data/sidebar/pk2-test')
|
|
|
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
|
|
.expect(HTTP_STATUS.OK);
|
|
|
|
expect(response.text).toMatch('pk2-test');
|
2021-03-06 18:56:45 +01:00
|
|
|
});
|
|
|
|
});
|