1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-21 07:29:37 +01:00

refactor: enable request test

This commit is contained in:
Juan Picado @jotadeveloper 2018-06-25 08:38:02 +02:00
parent 1fd50cc53e
commit 88996e92a5
No known key found for this signature in database
GPG Key ID: 18AC54485952D158

@ -2,11 +2,14 @@
import _ from 'lodash'; import _ from 'lodash';
import smartRequest, {PromiseAssert} from '../../lib/request'; import smartRequest, {PromiseAssert} from '../../lib/request';
import {mockServer} from '../api/mock';
import {HTTP_STATUS} from '../../../src/lib/constants';
import type {IRequestPromise} from '../../types'; import type {IRequestPromise} from '../../types';
describe.skip('Request Functional', () => { describe('Request Functional', () => {
const mockServerPort = 55547;
const restTest: string = "http://registry.npmjs.org/aaa"; const restTest: string = `http://localhost:${55547}/jquery`;
let mockRegistry;
describe('Request Functional', () => { describe('Request Functional', () => {
test('PromiseAssert', () => { test('PromiseAssert', () => {
@ -26,6 +29,15 @@ describe.skip('Request Functional', () => {
}); });
describe('smartRequest Rest', () => { describe('smartRequest Rest', () => {
beforeAll(async () => {
mockRegistry = await mockServer(mockServerPort).init();
});
afterAll(function(done) {
mockRegistry[0].stop();
done();
});
test('basic rest', (done) => { test('basic rest', (done) => {
const options: any = { const options: any = {
url: restTest, url: restTest,
@ -46,8 +58,8 @@ describe.skip('Request Functional', () => {
method: 'GET' method: 'GET'
}; };
// $FlowFixMe // $FlowFixMe
smartRequest(options).status(200).then((result)=> { smartRequest(options).status(HTTP_STATUS.OK).then((result)=> {
expect(JSON.parse(result).name).toBe('aaa'); expect(JSON.parse(result).name).toBe('jquery');
done(); done();
}) })
}); });