0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

test: add unit test for up-storage, getRemoteMetadata, fetchTarball

This commit is contained in:
Juan Picado @jotadeveloper 2017-12-19 09:56:40 +01:00 committed by juanpicado
parent 9d82eb8820
commit c602a4c9e7

View file

@ -25,14 +25,56 @@ describe('UpStorge', () => {
expect(proxy).toBeDefined();
});
test('should be get remote metadata', (done) => {
const proxy = generateProxy();
proxy.getRemoteMetadata('jquery', {}, (err, data, etag) => {
expect(err).toBeNull();
expect(_.isString(etag)).toBeTruthy();
expect(data.name).toBe('jquery');
done();
describe('UpStorge::getRemoteMetadata', () => {
test('should be get remote metadata', (done) => {
const proxy = generateProxy();
proxy.getRemoteMetadata('jquery', {}, (err, data, etag) => {
expect(err).toBeNull();
expect(_.isString(etag)).toBeTruthy();
expect(data.name).toBe('jquery');
done();
});
});
test('should be get remote metadata with etag', (done) => {
const proxy = generateProxy();
proxy.getRemoteMetadata('jquery', {etag: '123456'}, (err, data, etag) => {
expect(err).toBeNull();
expect(_.isString(etag)).toBeTruthy();
expect(data.name).toBe('jquery');
done();
});
});
test('should be get remote metadata package does not exist', (done) => {
const proxy = generateProxy();
proxy.getRemoteMetadata('@verdaccio/fake-package', {etag: '123456'}, (err, data, etag) => {
expect(err).not.toBeNull();
expect(err.statusCode).toBe(404);
expect(err.message).toMatch(/package doesn't exist on uplink/);
done();
});
});
});
describe('UpStorge::fetchTarball', () => {
test('should fetch a tarball from uplink', (done) => {
const proxy = generateProxy();
const tarball:string = 'https://registry.npmjs.org/aaa/-/aaa-0.0.1.tgz';
const stream = proxy.fetchTarball(tarball);
stream.on('error', function(err) {
expect(err).toBeNull();
done();
});
stream.on('content-length', function(contentLength) {
expect(contentLength).toBeDefined();
done();
});
});
});
});