1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +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 smartRequest, {PromiseAssert} from '../../lib/request';
import {mockServer} from '../api/mock';
import {HTTP_STATUS} from '../../../src/lib/constants';
import type {IRequestPromise} from '../../types';
describe.skip('Request Functional', () => {
const restTest: string = "http://registry.npmjs.org/aaa";
describe('Request Functional', () => {
const mockServerPort = 55547;
const restTest: string = `http://localhost:${55547}/jquery`;
let mockRegistry;
describe('Request Functional', () => {
test('PromiseAssert', () => {
@ -26,6 +29,15 @@ describe.skip('Request Functional', () => {
});
describe('smartRequest Rest', () => {
beforeAll(async () => {
mockRegistry = await mockServer(mockServerPort).init();
});
afterAll(function(done) {
mockRegistry[0].stop();
done();
});
test('basic rest', (done) => {
const options: any = {
url: restTest,
@ -46,8 +58,8 @@ describe.skip('Request Functional', () => {
method: 'GET'
};
// $FlowFixMe
smartRequest(options).status(200).then((result)=> {
expect(JSON.parse(result).name).toBe('aaa');
smartRequest(options).status(HTTP_STATUS.OK).then((result)=> {
expect(JSON.parse(result).name).toBe('jquery');
done();
})
});