0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-27 22:59:51 -05:00

Merge remote-tracking branch 'origin/master' into 4.x

This commit is contained in:
Juan Picado @jotadeveloper 2018-08-13 18:18:34 +02:00
commit 0ba1ccfabb
No known key found for this signature in database
GPG key ID: 18AC54485952D158
6 changed files with 80 additions and 25 deletions

View file

@ -2,6 +2,22 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="3.6.0"></a>
# [3.6.0](https://github.com/verdaccio/verdaccio/compare/v3.5.1...v3.6.0) (2018-08-13)
### Bug Fixes
* abort the stream to prevent overwriting existing tarbal ([2e5a409](https://github.com/verdaccio/verdaccio/commit/2e5a409))
* **webui:** search crash on ' ' as a value [#898](https://github.com/verdaccio/verdaccio/issues/898) ([#902](https://github.com/verdaccio/verdaccio/issues/902)) ([fd67698](https://github.com/verdaccio/verdaccio/commit/fd67698))
### Features
* **translations:** enable Chinese Simplified on website ([88b29e0](https://github.com/verdaccio/verdaccio/commit/88b29e0))
<a name="3.5.1"></a>
## [3.5.1](https://github.com/verdaccio/verdaccio/compare/v3.5.0...v3.5.1) (2018-08-02)

View file

@ -1,6 +1,6 @@
{
"name": "verdaccio",
"version": "3.5.1",
"version": "3.6.0",
"description": "Private npm repository server",
"author": {
"name": "Alex Kocharin",

View file

@ -426,6 +426,7 @@ class LocalStorage implements IStorage {
writeStream.on('error', (err) => {
if (err.code === fileExist) {
uploadStream.emit('error', ErrorCode.getConflict());
uploadStream.abort();
} else if (err.code === noSuchFile) {
// check if package exists to throw an appropriate message
this.getPackageMetadata(name, function(_err, res) {

View file

@ -89,7 +89,7 @@ export default class Home extends React.Component {
handleSearchInput(e) {
this.setState({
query: e.target.value
query: e.target.value.trim()
});
}

View file

@ -11,7 +11,6 @@ import {readFile} from '../../functional/lib/test.utils';
import {generatePackageTemplate} from '../../../src/lib/storage-utils';
import {generateNewVersion} from '../../lib/utils-test';
const readMetadata = (fileName: string = 'metadata') => readFile(`../../unit/partials/${fileName}`);
import type {Config, MergeTags} from '@verdaccio/types';
@ -339,17 +338,18 @@ describe('LocalStorage', () => {
test('should fails on add a duplicated new tarball ', (done) => {
const tarballData = JSON.parse(readMetadata('addTarball'));
const stream = storage.addTarball(pkgName, tarballName);
let spy;
// $FlowFixMe
spy = jest.spyOn(stream && stream._readableState && stream._readableState.pipes, 'abort');
stream.on('error', (err) => {
expect(err).not.toBeNull();
expect(err.statusCode).toEqual(HTTP_STATUS.CONFLICT);
expect(err.message).toMatch(/this package is already present/);
expect(err.message).toMatch(/this package is already present/);
});
stream.on('success', function(){
expect(spy).toHaveBeenCalled();
done();
});
stream.on('success', function() {
done();
});
stream.end(new Buffer(tarballData.data, 'base64'));
stream.done();
});
@ -397,26 +397,25 @@ describe('LocalStorage', () => {
stream.done();
});
describe('LocalStorage::removeTarball', () => {
});
describe('LocalStorage::removeTarball', () => {
test('should remove a tarball', (done) => {
storage.removeTarball(pkgName, tarballName2, 'rev', (err, pkg) => {
expect(err).toBeNull();
expect(pkg).toBeUndefined();
done();
});
});
test('should remove a tarball that does not exist', (done) => {
storage.removeTarball(pkgName, tarballName2, 'rev', (err) => {
expect(err).not.toBeNull();
expect(err.statusCode).toEqual(HTTP_STATUS.NOT_FOUND);
expect(err.message).toMatch(/no such file available/);
done();
});
test('should remove a tarball', (done) => {
storage.removeTarball(pkgName, tarballName2, 'rev', (err, pkg) => {
expect(err).toBeNull();
expect(pkg).toBeUndefined();
done();
});
});
test('should remove a tarball that does not exist', (done) => {
storage.removeTarball(pkgName, tarballName2, 'rev', (err) => {
expect(err).not.toBeNull();
expect(err.statusCode).toEqual(HTTP_STATUS.NOT_FOUND);
expect(err.message).toMatch(/no such file available/);
done();
});
});
});
describe('LocalStorage::getTarball', () => {

View file

@ -0,0 +1,39 @@
/**
* Home Component
*/
import React from 'react';
import { mount } from 'enzyme';
import Home from '../../../../src/webui/modules/home/index';
describe('<Home /> Component', () => {
let wrapper;
beforeEach(() => {
wrapper = mount(<Home />);
});
it('handleSearchInput - should match the search query', () => {
const { handleSearchInput } = wrapper.instance();
const result = 'test query string one';
const input = {
target: {
value: result
}
};
handleSearchInput(input);
expect(wrapper.state('query')).toBe(result);
});
it('handleSearchInput - should match the trimmed search query', () => {
const { handleSearchInput } = wrapper.instance();
const result = ' ';
const input = {
target: {
value: result
}
};
handleSearchInput(input);
expect(wrapper.state('query')).toBe(result.trim());
});
});