mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
5167bb528f
* UI search uses search endpoint for global search * improve sorting and error handling * give priority to private packages * order by private package * add tests, improve testing * add changeset * addjust settings * remove old index search implementation * update lock file * relocate fastify package * fix circular dependency * fix wrong import * fix tests
62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import path from 'path';
|
|
import supertest from 'supertest';
|
|
|
|
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
|
import { setup } from '@verdaccio/logger';
|
|
|
|
import { initializeServer } from './helper';
|
|
|
|
setup([]);
|
|
|
|
const mockManifest = jest.fn();
|
|
jest.mock('@verdaccio/ui-theme', () => mockManifest());
|
|
|
|
describe('test web server', () => {
|
|
beforeAll(() => {
|
|
mockManifest.mockReturnValue(() => ({
|
|
manifestFiles: {
|
|
js: ['runtime.js', 'vendors.js', 'main.js'],
|
|
},
|
|
staticPath: path.join(__dirname, 'static'),
|
|
manifest: require('./partials/manifest/manifest.json'),
|
|
}));
|
|
});
|
|
|
|
afterEach(() => {
|
|
jest.clearAllMocks();
|
|
mockManifest.mockClear();
|
|
});
|
|
|
|
describe('render', () => {
|
|
test('should return the root', async () => {
|
|
return supertest(await initializeServer('default-test.yaml'))
|
|
.get('/')
|
|
.set('Accept', HEADERS.TEXT_HTML)
|
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
|
|
.expect(HTTP_STATUS.OK);
|
|
});
|
|
|
|
test('should return the body for a package detail page', async () => {
|
|
return supertest(await initializeServer('default-test.yaml'))
|
|
.get('/-/web/section/some-package')
|
|
.set('Accept', HEADERS.TEXT_HTML)
|
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
|
|
.expect(HTTP_STATUS.OK);
|
|
});
|
|
|
|
test.skip('should static file not found', async () => {
|
|
return supertest(await initializeServer('default-test.yaml'))
|
|
.get('/-/static/not-found.js')
|
|
.set('Accept', HEADERS.TEXT_HTML)
|
|
.expect(HTTP_STATUS.NOT_FOUND);
|
|
});
|
|
|
|
test('should static file found', async () => {
|
|
return supertest(await initializeServer('default-test.yaml'))
|
|
.get('/-/static/main.js')
|
|
.set('Accept', HEADERS.TEXT_HTML)
|
|
.expect(HTTP_STATUS.OK);
|
|
});
|
|
});
|
|
});
|