diff --git a/jest.config.js b/jest.config.js
index ccb35e9df..6405c2ddd 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -8,6 +8,7 @@ module.exports = {
'node_modules',
'fixtures'
],
+ 'testEnvironment': 'jest-environment-jsdom-global',
'testRegex': '(/test/unit.*\\.spec|test/functional.*\\.func|/test/webui/.*\\.spec)\\.js',
// 'testRegex': '(test/functional.*\\.func)\\.js'
'setupFiles': [
diff --git a/package.json b/package.json
index af2be7af3..197fad7ea 100644
--- a/package.json
+++ b/package.json
@@ -48,12 +48,12 @@
"unix-crypt-td-js": "^1.0.0"
},
"devDependencies": {
- "@verdaccio/types": "0.1.3",
+ "@verdaccio/types": "^0.2.0",
"axios": "0.17.1",
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-eslint": "8.2.1",
- "babel-jest": "^21.2.0",
+ "babel-jest": "^22.0.6",
"babel-loader": "7.1.2",
"babel-plugin-flow-runtime": "0.15.0",
"babel-plugin-transform-async-to-generator": "^6.24.1",
@@ -96,7 +96,8 @@
"html-webpack-plugin": "2.30.1",
"identity-obj-proxy": "^3.0.0",
"in-publish": "2.0.0",
- "jest": "^21.2.1",
+ "jest": "22.0.6",
+ "jest-environment-jsdom-global": "1.0.2",
"localstorage-memory": "1.0.2",
"node-sass": "4.7.2",
"normalize.css": "7.0.0",
@@ -104,7 +105,7 @@
"prop-types": "15.6.0",
"react": "16.2.0",
"react-dom": "16.2.0",
- "react-hot-loader": "3.0.0-beta.7",
+ "react-hot-loader": "4.0.0-beta.14",
"react-router-dom": "4.2.2",
"react-syntax-highlighter": "5.8.0",
"rimraf": "2.6.2",
diff --git a/src/lib/local-storage.js b/src/lib/local-storage.js
index f5917180d..ae79469ca 100644
--- a/src/lib/local-storage.js
+++ b/src/lib/local-storage.js
@@ -34,6 +34,11 @@ import type {
IPackageStorage,
} from '@verdaccio/local-storage';
+import type {
+ IUploadTarball,
+ IReadTarball,
+} from '@verdaccio/streams';
+
/**
* Implements Storage interface (same for storage.js, local-storage.js, up-storage.js).
*/
@@ -403,7 +408,7 @@ class LocalStorage implements IStorage {
let length = 0;
const shaOneHash = Crypto.createHash('sha1');
- const uploadStream = new UploadTarball();
+ const uploadStream: IUploadTarball = new UploadTarball();
const _transform = uploadStream._transform;
const storage = this._getLocalStorage(name);
@@ -431,7 +436,7 @@ class LocalStorage implements IStorage {
return uploadStream;
}
- const writeStream = storage.writeTarball(filename);
+ const writeStream: IUploadTarball = storage.writeTarball(filename);
writeStream.on('error', (err) => {
if (err.code === fileExist) {
@@ -512,7 +517,7 @@ class LocalStorage implements IStorage {
* @return {ReadTarball}
*/
_createFailureStreamResponse() {
- const stream = new ReadTarball();
+ const stream: IReadTarball = new ReadTarball();
process.nextTick(() => {
stream.emit('error', this._getFileNotAvailable());
@@ -528,7 +533,7 @@ class LocalStorage implements IStorage {
* @return {ReadTarball}
*/
_streamSuccessReadTarBall(storage: any, filename: string) {
- const stream = new ReadTarball();
+ const stream: IReadTarball = new ReadTarball();
const readTarballStream = storage.readTarball(filename);
const e404 = Utils.ErrorCode.get404;
diff --git a/test/.eslintrc b/test/.eslintrc
index 163cd741c..0cb9dbe6a 100644
--- a/test/.eslintrc
+++ b/test/.eslintrc
@@ -7,6 +7,9 @@
"mocha": true,
"es6": true
},
+ "globals": {
+ "jsdom": true
+ },
"rules": {
"valid-jsdoc": 0,
"no-redeclare": 1,
diff --git a/test/webui/components/help.spec.js b/test/webui/components/help.spec.js
index 852273319..704c61132 100644
--- a/test/webui/components/help.spec.js
+++ b/test/webui/components/help.spec.js
@@ -7,19 +7,10 @@ import SyntaxHighlighter from 'react-syntax-highlighter/dist/light';
import Help from '../../../src/webui/src/components/Help';
describe(' component', () => {
- beforeEach(() => {
- /**
- * @see https://github.com/facebook/jest/issues/890
- */
- Object.defineProperty(window.location, 'origin', {
- writable: true,
- value: 'http://example.com'
- });
- });
+
it('should set html from props with / base path', () => {
- Object.defineProperty(window.location, 'pathname', {
- writable: true,
- value: '/'
+ jsdom.reconfigure({
+ url: "http://example.com/"
});
const wrapper = shallow();
expect(
@@ -33,9 +24,8 @@ describe(' component', () => {
});
it('should set html from props with someOtherPath', () => {
- Object.defineProperty(window.location, 'pathname', {
- writable: true,
- value: '/someOtherPath'
+ jsdom.reconfigure({
+ url: "http://example.com/someOtherPath"
});
const wrapper = shallow();
expect(
diff --git a/yarn.lock b/yarn.lock
index d6ee9ce79..306fb4478 100644
Binary files a/yarn.lock and b/yarn.lock differ