2021-03-06 12:56:45 -05:00
|
|
|
import path from 'path';
|
|
|
|
import supertest from 'supertest';
|
2021-10-29 10:33:05 -05:00
|
|
|
|
2021-09-25 17:08:00 -05:00
|
|
|
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
2021-10-29 10:33:05 -05:00
|
|
|
import { setup } from '@verdaccio/logger';
|
|
|
|
|
2021-03-06 12:56:45 -05:00
|
|
|
import { initializeServer } from './helper';
|
|
|
|
|
|
|
|
setup([]);
|
|
|
|
|
|
|
|
const mockManifest = jest.fn();
|
|
|
|
jest.mock('@verdaccio/ui-theme', () => mockManifest());
|
|
|
|
|
|
|
|
describe('test web server', () => {
|
|
|
|
afterEach(() => {
|
|
|
|
jest.clearAllMocks();
|
|
|
|
mockManifest.mockClear();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should OK to package api', async () => {
|
2021-04-02 08:59:47 -05:00
|
|
|
mockManifest.mockReturnValue(() => ({
|
|
|
|
staticPath: path.join(__dirname, 'static'),
|
|
|
|
manifestFiles: {
|
|
|
|
js: ['runtime.js', 'vendors.js', 'main.js'],
|
|
|
|
},
|
2021-03-06 12:56:45 -05:00
|
|
|
manifest: require('./partials/manifest/manifest.json'),
|
2021-04-02 08:59:47 -05:00
|
|
|
}));
|
2021-03-06 12:56:45 -05:00
|
|
|
const response = await supertest(await initializeServer('default-test.yaml'))
|
2022-01-15 14:12:28 -05:00
|
|
|
.get('/-/verdaccio/data/packages')
|
2021-03-06 12:56:45 -05:00
|
|
|
.set('Accept', HEADERS.JSON_CHARSET)
|
|
|
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
|
|
.expect(HTTP_STATUS.OK);
|
|
|
|
expect(response.body).toEqual([]);
|
|
|
|
});
|
|
|
|
});
|