mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-23 22:27:34 -05:00
66f4197236
* chore: test * chore: add * chore: more progress * chore: progress in migration, fix prettier parser * chore: reduce tsc errors * chore: refactor storage utils types * chore: refactor utils types * chore: refactor local storage types * chore: refactor config utils types * chore: refactor tsc types * refactor: apply eslint fix, tabs etc * chore: fix lint errors * test: update unit test conf to typescript setup few test refactored to typescript * chore: enable more unit test migrate to typescript * chore: migrate storage test to tsc * chore: migrate up storage test to tsc * refactor: enable plugin and auth test * chore: migrate plugin loader test * chore: update dependencies * chore: migrate functional test to typescript * chore: add codecove * chore: update express * chore: downgrade puppeteer The latest version does not seems to work properly fine. * chore: update dependencies
80 lines
2 KiB
TypeScript
80 lines
2 KiB
TypeScript
import _ from 'lodash';
|
|
import smartRequest, {PromiseAssert} from '../../lib/request';
|
|
import {mockServer} from '../__helper/mock';
|
|
import {HTTP_STATUS} from '../../../src/lib/constants';
|
|
import {IRequestPromise} from '../../types';
|
|
|
|
describe('Request Functional', () => {
|
|
const mockServerPort = 55547;
|
|
const restTest = `http://localhost:${55547}/jquery`;
|
|
let mockRegistry;
|
|
|
|
describe('Request Functional', () => {
|
|
test('PromiseAssert', () => {
|
|
expect(_.isFunction(smartRequest)).toBeTruthy();
|
|
});
|
|
|
|
test('basic resolve', (done) => {
|
|
const requestPromise: IRequestPromise = new PromiseAssert((resolve, reject) => {
|
|
resolve(1);
|
|
});
|
|
// $FlowFixMe
|
|
requestPromise.then((result) => {
|
|
expect(result).toBe(1);
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
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,
|
|
method: 'GET'
|
|
};
|
|
|
|
smartRequest(options).then((result)=> {
|
|
expect(_.isString(result)).toBeTruthy();
|
|
done();
|
|
})
|
|
});
|
|
|
|
describe('smartRequest Status', () => {
|
|
|
|
test('basic check status 200', (done) => {
|
|
const options: any = {
|
|
url: restTest,
|
|
method: 'GET'
|
|
};
|
|
// $FlowFixMe
|
|
smartRequest(options).status(HTTP_STATUS.OK).then((result)=> {
|
|
expect(JSON.parse(result).name).toBe('jquery');
|
|
done();
|
|
})
|
|
});
|
|
|
|
test('basic check status 404', (done) => {
|
|
const options: any = {
|
|
url: 'http://www.google.fake',
|
|
method: 'GET'
|
|
};
|
|
// $FlowFixMe
|
|
smartRequest(options).status(HTTP_STATUS.NOT_FOUND).then((result)=> {
|
|
// this never is resolved
|
|
}, function(error) {
|
|
expect(error.code).toBe('ENOTFOUND');
|
|
done();
|
|
})
|
|
});
|
|
});
|
|
});
|
|
});
|