From 0cabe194d7d43a7ddbefb43417faae5fed530325 Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Mon, 26 Jun 2017 11:15:30 +0200 Subject: [PATCH 01/11] Upgraded version of dependencies in whole repository. --- package.json | 4 +- .../ckeditor5-dev-bundler-rollup/package.json | 24 +++++----- packages/ckeditor5-dev-env/package.json | 24 +++++----- packages/ckeditor5-dev-lint/package.json | 18 ++++---- packages/ckeditor5-dev-tests/package.json | 46 +++++++++---------- packages/ckeditor5-dev-utils/package.json | 20 ++++---- 6 files changed, 68 insertions(+), 68 deletions(-) diff --git a/package.json b/package.json index aa5c3a976..f9b97fd1d 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "gulp": "^3.9.1", "guppy-pre-commit": "^0.4.0", "istanbul": "^0.4.4", - "lerna": "2.0.0-rc.1", - "mocha": "^3.0.2" + "lerna": "2.0.0-rc.5", + "mocha": "^3.4.2" }, "engines": { "node": ">=6.0.0", diff --git a/packages/ckeditor5-dev-bundler-rollup/package.json b/packages/ckeditor5-dev-bundler-rollup/package.json index f43922706..3cc15c9da 100644 --- a/packages/ckeditor5-dev-bundler-rollup/package.json +++ b/packages/ckeditor5-dev-bundler-rollup/package.json @@ -7,29 +7,29 @@ "dependencies": { "@ckeditor/ckeditor5-dev-compiler": "^6.0.2", "@ckeditor/ckeditor5-dev-utils": "^3.0.0", - "babel-plugin-external-helpers": "^6.18.0", - "babel-preset-es2015": "^6.18.0", + "babel-plugin-external-helpers": "^6.22.0", + "babel-preset-es2015": "^6.24.1", "gulp": "^3.9.1", "gulp-cssnano": "^2.1.2", - "gulp-filter": "^4.0.0", + "gulp-filter": "^5.0.0", "gulp-rename": "^1.2.2", - "gulp-replace": "^0.5.4", - "gulp-uglify": "^2.0.0", - "gulp-util": "^3.0.7", + "gulp-replace": "^0.6.1", + "gulp-uglify": "^3.0.0", + "gulp-util": "^3.0.8", "gzip-size": "^3.0.0", "minimist": "^1.2.0", "mkdirp": "^0.5.1", "pretty-bytes": "^4.0.2", - "regenerator-runtime": "^0.10.0", - "rollup": "^0.36.4", - "rollup-plugin-babel": "^2.6.1", + "regenerator-runtime": "^0.10.5", + "rollup": "^0.43.0", + "rollup-plugin-babel": "^2.7.1", "stream-to-promise": "^2.2.0" }, "devDependencies": { - "chai": "^3.5.0", - "mocha": "^3.0.2", + "chai": "^4.0.2", + "mocha": "^3.4.2", "mockery": "^2.0.0", - "sinon": "^1.17.4" + "sinon": "^2.3.5" }, "engines": { "node": ">=6.0.0", diff --git a/packages/ckeditor5-dev-env/package.json b/packages/ckeditor5-dev-env/package.json index a4ebb2314..1eb7349cb 100644 --- a/packages/ckeditor5-dev-env/package.json +++ b/packages/ckeditor5-dev-env/package.json @@ -9,26 +9,26 @@ "chalk": "^1.1.3", "compare-func": "^1.3.2", "concat-stream": "^1.6.0", - "conventional-changelog": "^1.1.0", + "conventional-changelog": "^1.1.3", "conventional-commits-filter": "^1.0.0", "conventional-commits-parser": "^1.3.0", - "del": "^2.2.2", - "fs-extra": "^1.0.0", + "del": "^3.0.0", + "fs-extra": "^3.0.1", "git-raw-commits": "^1.2.0", - "github": "^9.0.0", - "glob": "^7.1.1", - "inquirer": "^3.0.5", + "github": "^9.2.0", + "glob": "^7.1.2", + "inquirer": "^3.1.1", "minimist": "^1.2.0", "parse-github-url": "^1.0.0", - "request": "^2.79.0", + "request": "^2.81.0", "semver": "^5.3.0" }, "devDependencies": { - "chai": "^3.5.0", - "handlebars": "^4.0.6", - "mockery": "^1.7.0", - "proxyquire": "^1.7.11", - "sinon": "^1.17.4" + "chai": "^4.0.2", + "handlebars": "^4.0.10", + "mockery": "^2.0.0", + "proxyquire": "^1.8.0", + "sinon": "^2.3.5" }, "engines": { "node": ">=6.0.0", diff --git a/packages/ckeditor5-dev-lint/package.json b/packages/ckeditor5-dev-lint/package.json index 90d96107d..97d4f9b03 100644 --- a/packages/ckeditor5-dev-lint/package.json +++ b/packages/ckeditor5-dev-lint/package.json @@ -5,19 +5,19 @@ "keywords": [], "main": "lib/index.js", "dependencies": { - "git-guppy": "^1.2.1", + "git-guppy": "^2.1.0", "gulp": "^3.9.1", - "gulp-eslint": "^3.0.1", - "gulp-filter": "^4.0.0", - "gulp-util": "^3.0.7" + "gulp-eslint": "^4.0.0", + "gulp-filter": "^5.0.0", + "gulp-util": "^3.0.8" }, "devDependencies": { - "chai": "^3.5.0", + "chai": "^4.0.2", "guppy-pre-commit": "^0.4.0", - "mockery": "^1.7.0", - "sinon": "^1.17.4", - "through2": "^2.0.1", - "vinyl": "^1.1.1" + "mockery": "^2.0.0", + "sinon": "^2.3.5", + "through2": "^2.0.3", + "vinyl": "^2.0.2" }, "engines": { "node": ">=6.0.0", diff --git a/packages/ckeditor5-dev-tests/package.json b/packages/ckeditor5-dev-tests/package.json index 29259f5ed..dc0b7b950 100644 --- a/packages/ckeditor5-dev-tests/package.json +++ b/packages/ckeditor5-dev-tests/package.json @@ -7,45 +7,45 @@ "dependencies": { "@ckeditor/ckeditor5-dev-utils": "^3.0.0", "@ckeditor/ckeditor5-dev-webpack-plugin": "^2.0.10", - "babel-core": "^6.21.0", - "babel-loader": "^6.2.5", - "babel-plugin-transform-es2015-modules-commonjs": "^6.18.0", - "chai": "^3.5.0", - "chokidar": "^1.6.1", + "babel-core": "^6.25.0", + "babel-loader": "^7.1.0", + "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", + "chai": "^4.0.2", + "chokidar": "^1.7.0", "commonmark": "^0.27.0", - "css-loader": "^0.28.0", - "del": "^2.2.2", + "css-loader": "^0.28.4", + "del": "^3.0.0", "dom-combiner": "^0.1.2", - "fs-extra": "^2.0.0", - "glob": "^7.1.1", - "gulp-util": "^3.0.7", + "fs-extra": "^3.0.1", + "glob": "^7.1.2", + "gulp-util": "^3.0.8", "istanbul-instrumenter-loader": "^2.0.0", - "karma": "^1.3.0", + "karma": "^1.7.0", "karma-chai": "^0.1.0", - "karma-chrome-launcher": "^2.0.0", + "karma-chrome-launcher": "^2.2.0", "karma-coverage": "^1.1.1", - "karma-firefox-launcher": "^1.0.0", - "karma-mocha": "^1.2.0", - "karma-mocha-reporter": "^2.2.0", + "karma-firefox-launcher": "^1.0.1", + "karma-mocha": "^1.3.0", + "karma-mocha-reporter": "^2.2.3", "karma-sinon": "^1.0.5", "karma-sourcemap-loader": "^0.3.7", - "karma-webpack": "^2.0.1", + "karma-webpack": "^2.0.3", "lodash": "^4.17.4", "mgit2": "^0.5.1", "minimist": "^1.2.0", - "mocha": "^3.1.2", + "mocha": "^3.4.2", "mockery": "^2.0.0", - "node-sass": "^4.5.0", + "node-sass": "^4.5.3", "raw-loader": "^0.5.1", - "sass-loader": "^6.0.3", + "sass-loader": "^6.0.6", "sinon": "^1.17.6", - "style-loader": "^0.16.1", - "webpack": "^2.3.3" + "style-loader": "^0.18.2", + "webpack": "^3.0.0" }, "devDependencies": { - "chai": "^3.5.0", + "chai": "^4.0.2", "mockery": "^2.0.0", - "sinon": "^1.17.7" + "sinon": "^2.3.5" }, "engines": { "node": ">=6.0.0", diff --git a/packages/ckeditor5-dev-utils/package.json b/packages/ckeditor5-dev-utils/package.json index 0a4da66de..c92920ed0 100644 --- a/packages/ckeditor5-dev-utils/package.json +++ b/packages/ckeditor5-dev-utils/package.json @@ -5,21 +5,21 @@ "keywords": [], "main": "lib/index.js", "dependencies": { - "acorn": "^4.0.8", - "del": "^2.2.1", + "acorn": "^5.0.3", + "del": "^3.0.0", "escodegen": "git://github.com/ma2ciek/escodegen.git", - "fs-extra": "^0.30.0", - "gulp-util": "^3.0.7", + "fs-extra": "^3.0.1", + "gulp-util": "^3.0.8", "javascript-stringify": "^1.6.0", - "pofile": "^1.0.5", - "shelljs": "^0.7.4", - "through2": "^2.0.1" + "pofile": "^1.0.8", + "shelljs": "^0.7.8", + "through2": "^2.0.3" }, "devDependencies": { - "chai": "^3.5.0", + "chai": "^4.0.2", "mockery": "^2.0.0", - "sinon": "^1.17.4", - "vinyl": "^1.1.1" + "sinon": "^2.3.5", + "vinyl": "^2.0.2" }, "engines": { "node": ">=6.0.0", From 5cc94f48f5736098edf872954f984e324f3b130c Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Mon, 26 Jun 2017 12:12:45 +0200 Subject: [PATCH 02/11] Fixed sinon's warnings. --- .../tests/tasks.js | 52 ++++++++++--------- .../tests/utils.js | 20 +++---- .../lib/translations/translationservice.js | 2 +- packages/ckeditor5-dev-utils/tests/tools.js | 24 ++++----- .../tests/translations/translationservice.js | 4 +- .../ckeditor5-dev-utils/tests/workspace.js | 18 +++---- 6 files changed, 60 insertions(+), 60 deletions(-) diff --git a/packages/ckeditor5-dev-bundler-rollup/tests/tasks.js b/packages/ckeditor5-dev-bundler-rollup/tests/tasks.js index 3438a93c4..5f2192c21 100644 --- a/packages/ckeditor5-dev-bundler-rollup/tests/tasks.js +++ b/packages/ckeditor5-dev-bundler-rollup/tests/tasks.js @@ -71,7 +71,7 @@ describe( 'bundle-tasks', () => { describe( 'compile()', () => { it( 'should compile packages', () => { - sandbox.stub( compiler.tasks, 'compile', config => config ); + sandbox.stub( compiler.tasks, 'compile' ).callsFake( config => config ); const result = tasks._compile( 'sourceBuildDir', [ 'package1' ] ); @@ -82,9 +82,9 @@ describe( 'bundle-tasks', () => { describe( '_generateBundleWithEntryPoint', () => { it( 'should generate bundle nad use existing entry point', () => { - sandbox.stub( tasks, '_generateJsBundle', config => Promise.resolve( config ) ); - sandbox.stub( tasks, '_generateCssBundle', config => Promise.resolve( config ) ); - sandbox.stub( path, 'join', ( ...args ) => args.join( '/' ) ); + sandbox.stub( tasks, '_generateJsBundle' ).callsFake( config => Promise.resolve( config ) ); + sandbox.stub( tasks, '_generateCssBundle' ).callsFake( config => Promise.resolve( config ) ); + sandbox.stub( path, 'join' ).callsFake( ( ...args ) => args.join( '/' ) ); const promise = tasks._generateBundleWithEntryPoint( { rollupOptions: { @@ -114,13 +114,13 @@ describe( 'bundle-tasks', () => { describe( '_generateBundleWithoutEntryPoint()', () => { it( 'should create entry point and generate bundle', () => { - sandbox.stub( tasks, '_generateJsBundle', config => Promise.resolve( config ) ); - sandbox.stub( tasks, '_generateCssBundle', config => Promise.resolve( config ) ); - sandbox.stub( tasks, '_saveLocallyTemporaryEntryFile', () => ( { + sandbox.stub( tasks, '_generateJsBundle' ).callsFake( config => Promise.resolve( config ) ); + sandbox.stub( tasks, '_generateCssBundle' ).callsFake( config => Promise.resolve( config ) ); + sandbox.stub( tasks, '_saveLocallyTemporaryEntryFile' ).callsFake( () => ( { temporaryEntryFilePath: 'tempEntryPoint', bundleTmpDir: 'bundleTemp', } ) ); - sandbox.stub( path, 'join', ( ...args ) => args.join( '/' ) ); + sandbox.stub( path, 'join' ).callsFake( ( ...args ) => args.join( '/' ) ); const promise = tasks._generateBundleWithoutEntryPoint( { rollupOptions: { @@ -153,9 +153,9 @@ describe( 'bundle-tasks', () => { describe( '_saveLocallyTemporaryEntryFile()', () => { it( 'should create temporary file with given name', () => { sandbox.stub( mkdirp, 'sync' ); - sandbox.stub( fs, 'mkdtempSync', path => path + 'temp' ); - sandbox.stub( path, 'join', ( x, y ) => x + '/' + y ); - sandbox.stub( path, 'sep', '/' ); + sandbox.stub( fs, 'mkdtempSync' ).callsFake( path => path + 'temp' ); + sandbox.stub( path, 'join' ).callsFake( ( x, y ) => x + '/' + y ); + sandbox.stub( path, 'sep' ).value( '/' ); const createEntryFileStub = sandbox.stub( bundler, 'createEntryFile' ); const result = tasks._saveLocallyTemporaryEntryFile( { @@ -194,9 +194,9 @@ describe( 'bundle-tasks', () => { describe( '_generateCssBundle', () => { it( 'should copy css files', () => { - sandbox.stub( path, 'join', ( ...args ) => args.join( '/' ) ); - sandbox.stub( path, 'dirname', x => x.split( '/' ).slice( 0, -1 ).join( '/' ) ); - sandbox.stub( tools, 'copyFile', ( source, dest ) => Promise.resolve( { source, dest } ) ); + sandbox.stub( path, 'join' ).callsFake( ( ...args ) => args.join( '/' ) ); + sandbox.stub( path, 'dirname' ).callsFake( x => x.split( '/' ).slice( 0, -1 ).join( '/' ) ); + sandbox.stub( tools, 'copyFile' ).callsFake( ( source, dest ) => Promise.resolve( { source, dest } ) ); const promise = tasks._generateCssBundle( { sourceBuildDir: 'sourceBuildDir', @@ -213,7 +213,7 @@ describe( 'bundle-tasks', () => { describe( '_rollupBundle()', () => { it( 'should create js bundle', () => { - sandbox.stub( rollup, 'rollup', config => Promise.resolve( config ) ); + sandbox.stub( rollup, 'rollup' ).callsFake( config => Promise.resolve( config ) ); const promise = tasks._rollupBundle( 'entryPoint' ); return promise.then( result => { @@ -268,18 +268,19 @@ describe( 'bundle-tasks', () => { const stream1 = gulp.src( [] ); const stream2 = gulp.src( [] ); - sandbox.stub( tasks, '_minifyJs', text => { + sandbox.stub( tasks, '_minifyJs' ).callsFake( text => { expect( text ).to.equal( 'destinationPath/fileName' ); return stream1; } ); - sandbox.stub( tasks, '_minifyCss', text => { + sandbox.stub( tasks, '_minifyCss' ).callsFake( text => { expect( text ).to.equal( 'destinationPath/fileName' ); return stream2; } ); - sandbox.stub( path, 'join', ( ...args ) => args.join( '/' ) ); + + sandbox.stub( path, 'join' ).callsFake( ( ...args ) => args.join( '/' ) ); return tasks._minify( 'destinationPath', 'fileName' ); } ); @@ -287,11 +288,12 @@ describe( 'bundle-tasks', () => { describe( '_minifyJs', () => { it( 'should minify js file', () => { - sandbox.stub( gulp, 'src', () => ( { + sandbox.stub( gulp, 'src' ).callsFake( () => ( { pipe: () => {} } ) ); - sandbox.stub( path, 'dirname', path => path.split( '/' ).slice( 0, -1 ).join( '/' ) ); - const saveMinified = sandbox.stub( utils, 'saveFileFromStreamAsMinified', path => path ); + + sandbox.stub( path, 'dirname' ).callsFake( path => path.split( '/' ).slice( 0, -1 ).join( '/' ) ); + const saveMinified = sandbox.stub( utils, 'saveFileFromStreamAsMinified' ).callsFake( path => path ); tasks._minifyJs( 'path/to/editor' ); @@ -301,10 +303,10 @@ describe( 'bundle-tasks', () => { describe( '_minifyCss', () => { it( 'should minify css file', () => { - sandbox.stub( gulp, 'src', () => ( { + sandbox.stub( gulp, 'src' ).callsFake( () => ( { pipe: () => {} } ) ); - sandbox.stub( path, 'dirname', path => path.split( '/' ).slice( 0, -1 ).join( '/' ) ); + sandbox.stub( path, 'dirname' ).callsFake( path => path.split( '/' ).slice( 0, -1 ).join( '/' ) ); const saveMinified = sandbox.stub( utils, 'saveFileFromStreamAsMinified' ); tasks._minifyCss( 'path/to/editor' ); @@ -322,14 +324,14 @@ describe( 'bundle-tasks', () => { 'editor.min.css': { size: 10 }, }; - sandbox.stub( utils, 'getFilesSizeStats', files => { + sandbox.stub( utils, 'getFilesSizeStats' ).callsFake( files => { return files.map( fileName => ( { name: fileName, size: fileStats[ fileName ].size, } ) ); } ); - sandbox.stub( utils, 'showFilesSummary', ( text, stats ) => { + sandbox.stub( utils, 'showFilesSummary' ).callsFake( ( text, stats ) => { expect( stats ).to.deep.equal( [ { name: 'editor.js', size: 123 }, { name: 'editor.css', size: 50 }, diff --git a/packages/ckeditor5-dev-bundler-rollup/tests/utils.js b/packages/ckeditor5-dev-bundler-rollup/tests/utils.js index 3f9f5501a..58f6f21d8 100644 --- a/packages/ckeditor5-dev-bundler-rollup/tests/utils.js +++ b/packages/ckeditor5-dev-bundler-rollup/tests/utils.js @@ -27,8 +27,8 @@ describe( 'bundle-utils', () => { describe( 'maybeCleanDir()', () => { it( 'should clean directory if dir is provided', () => { - const cleanStub = sandbox.stub( tools, 'clean', () => Promise.resolve() ); - sandbox.stub( path, 'join', x => x ); + const cleanStub = sandbox.stub( tools, 'clean' ).callsFake( () => Promise.resolve() ); + sandbox.stub( path, 'join' ).callsFake( x => x ); const promise = utils.maybeCleanDir( 'dir' ); sinon.assert.calledWithExactly( cleanStub, 'dir', '' ); @@ -37,8 +37,8 @@ describe( 'bundle-utils', () => { } ); it( 'should return resolved promise if no dir is provided', () => { - const cleanStub = sandbox.stub( tools, 'clean', () => Promise.resolve() ); - sandbox.stub( path, 'join', x => x ); + const cleanStub = sandbox.stub( tools, 'clean' ).callsFake( () => Promise.resolve() ); + sandbox.stub( path, 'join' ).callsFake( x => x ); const promise = utils.maybeCleanDir(); sinon.assert.notCalled( cleanStub ); @@ -49,7 +49,7 @@ describe( 'bundle-utils', () => { describe( 'cleanFiles()', () => { it( 'should clean every file with specific filename', () => { - sandbox.stub( tools, 'clean', ( path, filePattern ) => { + sandbox.stub( tools, 'clean' ).callsFake( ( path, filePattern ) => { return { path, filePattern }; } ); @@ -64,7 +64,7 @@ describe( 'bundle-utils', () => { it( 'should return file size in bytes', () => { const filePath = 'path/to/file'; const size = 1337; - const statSyncMock = sandbox.stub( fs, 'statSync', () => { + const statSyncMock = sandbox.stub( fs, 'statSync' ).callsFake( () => { return { size }; } ); @@ -78,8 +78,8 @@ describe( 'bundle-utils', () => { const filePath = 'path/to/file'; const size = 1337; const fileContent = 'some string'; - const readFileSyncMock = sandbox.stub( fs, 'readFileSync', () => fileContent ); - const gzipSizeMock = sandbox.stub( gzipSize, 'sync', () => 1337 ); + const readFileSyncMock = sandbox.stub( fs, 'readFileSync' ).callsFake( () => fileContent ); + const gzipSizeMock = sandbox.stub( gzipSize, 'sync' ).callsFake( () => 1337 ); expect( utils.getGzippedFileSize( filePath ) ).to.be.equal( size ); sinon.assert.calledWithExactly( readFileSyncMock, filePath ); @@ -94,8 +94,8 @@ describe( 'bundle-utils', () => { size = 1337; gzippedSize = 543; - sandbox.stub( utils, 'getFileSize', () => size ); - sandbox.stub( utils, 'getGzippedFileSize', () => gzippedSize ); + sandbox.stub( utils, 'getFileSize' ).callsFake( () => size ); + sandbox.stub( utils, 'getGzippedFileSize' ).callsFake( () => gzippedSize ); } ); it( 'should returns an array with two elements', () => { diff --git a/packages/ckeditor5-dev-utils/lib/translations/translationservice.js b/packages/ckeditor5-dev-utils/lib/translations/translationservice.js index 0fa9eab41..3ad9336dd 100644 --- a/packages/ckeditor5-dev-utils/lib/translations/translationservice.js +++ b/packages/ckeditor5-dev-utils/lib/translations/translationservice.js @@ -99,7 +99,7 @@ module.exports = class TranslationService { // Loads translations from the po file. _loadPoFile( pathToPoFile ) { if ( !fs.existsSync( pathToPoFile ) ) { - console.warn( `PO file doesn't exist under the path: ${ pathToPoFile }.` ); + logger.warning( `PO file doesn't exist under the path: ${ pathToPoFile }.` ); return; } diff --git a/packages/ckeditor5-dev-utils/tests/tools.js b/packages/ckeditor5-dev-utils/tests/tools.js index 0955665ab..d407457b4 100644 --- a/packages/ckeditor5-dev-utils/tests/tools.js +++ b/packages/ckeditor5-dev-utils/tests/tools.js @@ -174,7 +174,7 @@ describe( 'utils', () => { it( 'should get directories in specified path', () => { const fs = require( 'fs' ); const directories = [ 'dir1', 'dir2', 'dir3' ]; - const readdirSyncStub = sandbox.stub( fs, 'readdirSync', () => directories ); + const readdirSyncStub = sandbox.stub( fs, 'readdirSync' ).callsFake( () => directories ); const isDirectoryStub = sandbox.stub( tools, 'isDirectory' ).returns( true ); const dirPath = 'path'; @@ -193,7 +193,7 @@ describe( 'utils', () => { it( 'should return true if path points to directory', () => { const fs = require( 'fs' ); - const statSyncStub = sandbox.stub( fs, 'statSync', () => ( { isDirectory: () => true } ) ); + const statSyncStub = sandbox.stub( fs, 'statSync' ).callsFake( () => ( { isDirectory: () => true } ) ); const path = 'path'; const result = tools.isDirectory( path ); @@ -205,7 +205,7 @@ describe( 'utils', () => { it( 'should return false if path does not point to directory', () => { const fs = require( 'fs' ); - const statSyncStub = sandbox.stub( fs, 'statSync', () => ( { isDirectory: () => false } ) ); + const statSyncStub = sandbox.stub( fs, 'statSync' ).callsFake( () => ( { isDirectory: () => false } ) ); const path = 'path'; const result = tools.isDirectory( path ); @@ -233,7 +233,7 @@ describe( 'utils', () => { it( 'should return true if path points to file', () => { const fs = require( 'fs' ); - const statSyncStub = sandbox.stub( fs, 'statSync', () => ( { isFile: () => true } ) ); + const statSyncStub = sandbox.stub( fs, 'statSync' ).callsFake( () => ( { isFile: () => true } ) ); const path = 'path'; const result = tools.isFile( path ); @@ -245,7 +245,7 @@ describe( 'utils', () => { it( 'should return false if path does not point to directory', () => { const fs = require( 'fs' ); - const statSyncStub = sandbox.stub( fs, 'statSync', () => ( { isFile: () => false } ) ); + const statSyncStub = sandbox.stub( fs, 'statSync' ).callsFake( () => ( { isFile: () => false } ) ); const path = 'path'; const result = tools.isFile( path ); @@ -293,7 +293,7 @@ describe( 'utils', () => { it( 'should read, update and save JSON file', () => { const path = 'path/to/file.json'; const fs = require( 'fs' ); - const readFileStub = sandbox.stub( fs, 'readFileSync', () => '{}' ); + const readFileStub = sandbox.stub( fs, 'readFileSync' ).callsFake( () => '{}' ); const modifiedJSON = { modified: true }; const writeFileStub = sandbox.stub( fs, 'writeFileSync' ); @@ -450,7 +450,7 @@ describe( 'utils', () => { it( 'should be defined', () => expect( tools.getGitUrlFromNpm ).to.be.a( 'function' ) ); it( 'should call npm view command', () => { - const shExecStub = sandbox.stub( tools, 'shExec', () => { + const shExecStub = sandbox.stub( tools, 'shExec' ).callsFake( () => { return JSON.stringify( repository ); } ); const url = tools.getGitUrlFromNpm( moduleName ); @@ -504,7 +504,7 @@ describe( 'utils', () => { const fs = require( 'fs-extra' ); it( 'rejects Promise when file does not exist', () => { - const readFileStub = sandbox.stub( fs, 'readFile', ( from, to, callback ) => { + const readFileStub = sandbox.stub( fs, 'readFile' ).callsFake( ( from, to, callback ) => { callback( 'Some error during readFile.' ); } ); @@ -517,11 +517,11 @@ describe( 'utils', () => { } ); it( 'rejects Promise when file cannot be saved', () => { - const readFileStub = sandbox.stub( fs, 'readFile', ( from, to, callback ) => { + const readFileStub = sandbox.stub( fs, 'readFile' ).callsFake( ( from, to, callback ) => { callback( null, 'Some data.' ); } ); - const outputFileStub = sandbox.stub( fs, 'outputFile', ( to, data, callback ) => { + const outputFileStub = sandbox.stub( fs, 'outputFile' ).callsFake( ( to, data, callback ) => { callback( 'Some error during outputFile.' ); } ); @@ -538,11 +538,11 @@ describe( 'utils', () => { } ); it( 'resolves Promise when file was copied', () => { - const readFileStub = sandbox.stub( fs, 'readFile', ( from, to, callback ) => { + const readFileStub = sandbox.stub( fs, 'readFile' ).callsFake( ( from, to, callback ) => { callback( null, 'Some data.' ); } ); - const outputFileStub = sandbox.stub( fs, 'outputFile', ( to, data, callback ) => { + const outputFileStub = sandbox.stub( fs, 'outputFile' ).callsFake( ( to, data, callback ) => { callback( null ); } ); diff --git a/packages/ckeditor5-dev-utils/tests/translations/translationservice.js b/packages/ckeditor5-dev-utils/tests/translations/translationservice.js index 594e728aa..151e61388 100644 --- a/packages/ckeditor5-dev-utils/tests/translations/translationservice.js +++ b/packages/ckeditor5-dev-utils/tests/translations/translationservice.js @@ -113,9 +113,7 @@ describe( 'translations', () => { it( 'should load po file from the package only once', () => { const translationService = new TranslationService( 'pl' ); - const loadPoFileSpy = sinon.spy(); - - sandbox.stub( translationService, '_loadPoFile', loadPoFileSpy ); + const loadPoFileSpy = sandbox.stub( translationService, '_loadPoFile' ); translationService.loadPackage( 'pathToPackage' ); translationService.loadPackage( 'pathToPackage' ); diff --git a/packages/ckeditor5-dev-utils/tests/workspace.js b/packages/ckeditor5-dev-utils/tests/workspace.js index fc43f6a1e..24cfb254f 100644 --- a/packages/ckeditor5-dev-utils/tests/workspace.js +++ b/packages/ckeditor5-dev-utils/tests/workspace.js @@ -60,7 +60,7 @@ describe( 'utils', () => { it( 'should return only ckeditor5 directories', () => { const workspacePath = '/workspace/path'; const sourceDirectories = [ 'tools', 'ckeditor5', 'ckeditor5-core', '.bin', 'ckeditor5-plugin-image' ]; - sandbox.stub( tools, 'getDirectories', () => sourceDirectories ); + sandbox.stub( tools, 'getDirectories' ).callsFake( () => sourceDirectories ); const directories = ckeditor5Dirs.getDirectories( workspacePath ); expect( directories.length ).to.equal( 2 ); @@ -103,8 +103,8 @@ describe( 'utils', () => { it( 'should return empty array if no dev directories were found - because of missing ckeditor5-* repos', () => { const wrongRepositoryInfo = { name: 'plugins/plugin' }; - sandbox.stub( ckeditor5Dirs, 'getDirectories', () => sourceDirectories ); - sandbox.stub( ckeditor5Dirs, 'getDependencies', () => dependencies ); + sandbox.stub( ckeditor5Dirs, 'getDirectories' ).callsFake( () => sourceDirectories ); + sandbox.stub( ckeditor5Dirs, 'getDependencies' ).callsFake( () => dependencies ); sandbox.stub( git, 'parseRepositoryUrl' ).returns( wrongRepositoryInfo ); const directories = ckeditor5Dirs.getDevDirectories( workspacePath, packageJSONDependencies, ckeditor5Path ); @@ -116,8 +116,8 @@ describe( 'utils', () => { it( 'should return empty array if no dev directories were found - because of missing ckeditor5-* dirs', () => { const wrongDirectories = [ 'tools', 'ckeditor5', '.bin' ]; - sandbox.stub( ckeditor5Dirs, 'getDirectories', () => wrongDirectories ); - sandbox.stub( ckeditor5Dirs, 'getDependencies', () => dependencies ); + sandbox.stub( ckeditor5Dirs, 'getDirectories' ).callsFake( () => wrongDirectories ); + sandbox.stub( ckeditor5Dirs, 'getDependencies' ).callsFake( () => dependencies ); sandbox.stub( git, 'parseRepositoryUrl' ).returns( repositoryInfo ); const directories = ckeditor5Dirs.getDevDirectories( workspacePath, packageJSONDependencies, ckeditor5Path ); @@ -127,8 +127,8 @@ describe( 'utils', () => { } ); it( 'should return only ckeditor5 directories in development mode', () => { - sandbox.stub( ckeditor5Dirs, 'getDirectories', () => sourceDirectories ); - sandbox.stub( ckeditor5Dirs, 'getDependencies', () => dependencies ); + sandbox.stub( ckeditor5Dirs, 'getDirectories' ).callsFake( () => sourceDirectories ); + sandbox.stub( ckeditor5Dirs, 'getDependencies' ).callsFake( () => dependencies ); sandbox.stub( git, 'parseRepositoryUrl' ).returns( repositoryInfo ); const directories = ckeditor5Dirs.getDevDirectories( workspacePath, packageJSONDependencies, ckeditor5Path ); @@ -145,8 +145,8 @@ describe( 'utils', () => { } ); it( 'should return only ckeditor5 directories in development mode, including root directory', () => { - sandbox.stub( ckeditor5Dirs, 'getDirectories', () => sourceDirectories ); - sandbox.stub( ckeditor5Dirs, 'getDependencies', () => dependencies ); + sandbox.stub( ckeditor5Dirs, 'getDirectories' ).callsFake( () => sourceDirectories ); + sandbox.stub( ckeditor5Dirs, 'getDependencies' ).callsFake( () => dependencies ); sandbox.stub( git, 'parseRepositoryUrl' ).returns( repositoryInfo ); const includeRoot = true; From ce62c9db6e5aa28df44fbd4f34b05d24686c60ea Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Mon, 31 Jul 2017 09:17:05 +0200 Subject: [PATCH 03/11] Adjusted tests in "ckeditor5-dev-env" package to the latest Sinon API. --- .../tasks/generatechangelogforsubpackages.js | 2 +- .../generatechangelogforsubrepositories.js | 7 +- .../tasks/releasesubrepositories.js | 2 +- .../utils/getsubpackagespaths.js | 2 +- .../utils/getsubrepositoriespaths.js | 2 +- .../utils/updatedependenciesversions.js | 10 +-- .../tests/translations/collect-utils.js | 16 +++-- .../tests/translations/download.js | 5 +- .../tests/translations/transifex-service.js | 69 +++++++++++-------- .../tests/translations/upload.js | 2 +- 10 files changed, 63 insertions(+), 54 deletions(-) diff --git a/packages/ckeditor5-dev-env/tests/release-tools/tasks/generatechangelogforsubpackages.js b/packages/ckeditor5-dev-env/tests/release-tools/tasks/generatechangelogforsubpackages.js index dbf5528b9..56eaef4cf 100644 --- a/packages/ckeditor5-dev-env/tests/release-tools/tasks/generatechangelogforsubpackages.js +++ b/packages/ckeditor5-dev-env/tests/release-tools/tasks/generatechangelogforsubpackages.js @@ -59,7 +59,7 @@ describe( 'dev-env/release-tools/tasks', () => { mockery.registerMock( '../utils/versions', stubs.versionUtils ); mockery.registerMock( '../utils/getnewreleasetype', stubs.getNewReleaseType ); - sandbox.stub( path, 'join', ( ...chunks ) => chunks.join( '/' ) ); + sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) ); generateChangelogForSubPackages = proxyquire( '../../../lib/release-tools/tasks/generatechangelogforsubpackages', { '@ckeditor/ckeditor5-dev-utils': { diff --git a/packages/ckeditor5-dev-env/tests/release-tools/tasks/generatechangelogforsubrepositories.js b/packages/ckeditor5-dev-env/tests/release-tools/tasks/generatechangelogforsubrepositories.js index 3c5b65c33..6434483f7 100644 --- a/packages/ckeditor5-dev-env/tests/release-tools/tasks/generatechangelogforsubrepositories.js +++ b/packages/ckeditor5-dev-env/tests/release-tools/tasks/generatechangelogforsubrepositories.js @@ -41,7 +41,7 @@ describe( 'dev-env/release-tools/tasks', () => { mockery.registerMock( '../utils/displayskippedpackages', stubs.displaySkippedPackages ); mockery.registerMock( '../utils/displaygeneratedchangelogs', stubs.displayGeneratedChangelogs ); - sandbox.stub( path, 'join', ( ...chunks ) => chunks.join( '/' ) ); + sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) ); generateChangelogForSubRepositories = proxyquire( '../../../lib/release-tools/tasks/generatechangelogforsubrepositories', { '@ckeditor/ckeditor5-dev-utils': { @@ -146,8 +146,9 @@ describe( 'dev-env/release-tools/tasks', () => { expect( chdirStub.secondCall.args[ 0 ] ).to.equal( '/tmp' ); expect( stubs.displaySkippedPackages.calledOnce ).to.equal( true ); + expect( stubs.displaySkippedPackages.firstCall.args[ 0 ] ).to.deep.equal( new Set( [ - '@ckeditor/ckeditor5-engine' + '/tmp/packages/ckeditor5-engine' ] ) ); } ); } ); @@ -179,7 +180,7 @@ describe( 'dev-env/release-tools/tasks', () => { expect( stubs.displaySkippedPackages.calledOnce ).to.equal( true ); expect( stubs.displaySkippedPackages.firstCall.args[ 0 ] ).to.deep.equal( new Set( [ - '@ckeditor/ckeditor5-core' + '/tmp/packages/ckeditor5-core' ] ) ); } ); } ); diff --git a/packages/ckeditor5-dev-env/tests/release-tools/tasks/releasesubrepositories.js b/packages/ckeditor5-dev-env/tests/release-tools/tasks/releasesubrepositories.js index 0eccccb6e..68ae7ee1a 100644 --- a/packages/ckeditor5-dev-env/tests/release-tools/tasks/releasesubrepositories.js +++ b/packages/ckeditor5-dev-env/tests/release-tools/tasks/releasesubrepositories.js @@ -89,7 +89,7 @@ describe( 'dev-env/release-tools/tasks', function() { mockery.registerMock( '../utils/cli', stubs.cli ); mockery.registerMock( '../utils/validatepackagetorelease', stubs.validatePackageToRelease ); - sandbox.stub( path, 'join', ( ...chunks ) => chunks.join( '/' ) ); + sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) ); releaseSubRepositories = proxyquire( '../../../lib/release-tools/tasks/releasesubrepositories', { '@ckeditor/ckeditor5-dev-utils': { diff --git a/packages/ckeditor5-dev-env/tests/release-tools/utils/getsubpackagespaths.js b/packages/ckeditor5-dev-env/tests/release-tools/utils/getsubpackagespaths.js index c96ca5e8e..4b6904136 100644 --- a/packages/ckeditor5-dev-env/tests/release-tools/utils/getsubpackagespaths.js +++ b/packages/ckeditor5-dev-env/tests/release-tools/utils/getsubpackagespaths.js @@ -21,7 +21,7 @@ describe( 'dev-env/release-tools/utils', () => { getPackageJsonStub = sandbox.stub(); getDirectoriesStub = sandbox.stub(); - sandbox.stub( path, 'join', ( ...chunks ) => chunks.join( '/' ) ); + sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) ); getSubPackagesPaths = proxyquire( '../../../lib/release-tools/utils/getsubpackagespaths', { './getpackagejson': getPackageJsonStub, diff --git a/packages/ckeditor5-dev-env/tests/release-tools/utils/getsubrepositoriespaths.js b/packages/ckeditor5-dev-env/tests/release-tools/utils/getsubrepositoriespaths.js index 61d922f1b..cdc27cba9 100644 --- a/packages/ckeditor5-dev-env/tests/release-tools/utils/getsubrepositoriespaths.js +++ b/packages/ckeditor5-dev-env/tests/release-tools/utils/getsubrepositoriespaths.js @@ -20,7 +20,7 @@ describe( 'dev-env/release-tools/utils', () => { getPackageJsonStub = sandbox.stub(); getDirectoriesStub = sandbox.stub(); - sandbox.stub( path, 'join', ( ...chunks ) => chunks.join( '/' ) ); + sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) ); getSubRepositoriesPaths = proxyquire( '../../../lib/release-tools/utils/getsubrepositoriespaths', { './getpackagejson': getPackageJsonStub, diff --git a/packages/ckeditor5-dev-env/tests/release-tools/utils/updatedependenciesversions.js b/packages/ckeditor5-dev-env/tests/release-tools/utils/updatedependenciesversions.js index 507461244..86798bee8 100644 --- a/packages/ckeditor5-dev-env/tests/release-tools/utils/updatedependenciesversions.js +++ b/packages/ckeditor5-dev-env/tests/release-tools/utils/updatedependenciesversions.js @@ -26,7 +26,7 @@ describe( 'dev-env/release-tools/utils', () => { it( 'does not update when package list is empty', () => { let json = {}; - sandbox.stub( tools, 'updateJSONFile', ( pathToJson, editJsonFunction ) => { + sandbox.stub( tools, 'updateJSONFile' ).callsFake( ( pathToJson, editJsonFunction ) => { json = editJsonFunction( json ); } ); @@ -42,7 +42,7 @@ describe( 'dev-env/release-tools/utils', () => { [ 'package-a', '1.1.0' ] ] ); - sandbox.stub( tools, 'updateJSONFile', ( pathToJson, editJsonFunction ) => { + sandbox.stub( tools, 'updateJSONFile' ).callsFake( ( pathToJson, editJsonFunction ) => { expect( pathToJson ).to.equal( 'path/to/json/file' ); json = editJsonFunction( json ); @@ -72,7 +72,7 @@ describe( 'dev-env/release-tools/utils', () => { [ 'package-dev-b', '0.1.0' ] ] ); - const updateJsonFileStub = sandbox.stub( tools, 'updateJSONFile', ( pathToJson, editJsonFunction ) => { + const updateJsonFileStub = sandbox.stub( tools, 'updateJSONFile' ).callsFake( ( pathToJson, editJsonFunction ) => { expect( pathToJson ).to.equal( 'path/to/json/file' ); json = editJsonFunction( json ); @@ -103,7 +103,7 @@ describe( 'dev-env/release-tools/utils', () => { [ 'package-d', '1.2.3' ] ] ); - sandbox.stub( tools, 'updateJSONFile', ( pathToJson, editJsonFunction ) => { + sandbox.stub( tools, 'updateJSONFile' ).callsFake( ( pathToJson, editJsonFunction ) => { json = editJsonFunction( json ); } ); @@ -129,7 +129,7 @@ describe( 'dev-env/release-tools/utils', () => { [ 'package-d', '1.2.3' ] ] ); - sandbox.stub( tools, 'updateJSONFile', ( pathToJson, editJsonFunction ) => { + sandbox.stub( tools, 'updateJSONFile' ).callsFake( ( pathToJson, editJsonFunction ) => { json = editJsonFunction( json ); } ); diff --git a/packages/ckeditor5-dev-env/tests/translations/collect-utils.js b/packages/ckeditor5-dev-env/tests/translations/collect-utils.js index de9dfd6e2..fd7888476 100644 --- a/packages/ckeditor5-dev-env/tests/translations/collect-utils.js +++ b/packages/ckeditor5-dev-env/tests/translations/collect-utils.js @@ -37,8 +37,8 @@ describe( 'collect-utils', () => { delSync: sandbox.spy() }; - sandbox.stub( process, 'cwd', () => path.join( 'workspace', 'ckeditor5' ) ); - sandbox.stub( del, 'sync', stubs.delSync ); + sandbox.stub( process, 'cwd' ).returns( path.join( 'workspace', 'ckeditor5' ) ); + sandbox.stub( del, 'sync' ).callsFake( stubs.delSync ); utils = proxyquire( '../../lib/translations/collect-utils', { '@ckeditor/ckeditor5-dev-utils': { @@ -66,12 +66,12 @@ describe( 'collect-utils', () => { 't( \'Italic [context: italic style]\' );': [ 'Italic [context: italic style]' ] }; - const globSyncStub = sandbox.stub( glob, 'sync', () => [ + const globSyncStub = sandbox.stub( glob, 'sync' ).returns( [ path.sep + path.join( 'ckeditor5-core', 'file1.js' ), path.sep + path.join( 'ckeditor5-utils', 'file2.js' ) ] ); - const readFileStub = sandbox.stub( fs, 'readFileSync', fileName => fileContents[ fileName ] ); + const readFileStub = sandbox.stub( fs, 'readFileSync' ).callsFake( fileName => fileContents[ fileName ] ); const translations = utils.collectTranslations(); @@ -112,9 +112,9 @@ describe( 'collect-utils', () => { [ path2 ]: '{}' }; - const readDirStub = sandbox.stub( fs, 'readdirSync', () => ( [ 'ckeditor5-core', 'ckeditor5-utils' ] ) ); - sandbox.stub( fs, 'existsSync', () => true ); - sandbox.stub( fs, 'readFileSync', filePath => fileContents[ filePath ] ); + const readDirStub = sandbox.stub( fs, 'readdirSync' ).returns( [ 'ckeditor5-core', 'ckeditor5-utils' ] ); + sandbox.stub( fs, 'existsSync' ).returns( true ); + sandbox.stub( fs, 'readFileSync' ).callsFake( filePath => fileContents[ filePath ] ); const contexts = utils.getContexts(); @@ -261,12 +261,14 @@ describe( 'collect-utils', () => { const context = { content: { util: 'Util' } }; const poContent = utils.createPotFileContent( context ); + /* eslint-disable indent */ expect( poContent ).to.be.equal( `msgctxt "Util" msgid "util" msgstr "util" ` ); + /* eslint-enable indent */ } ); } ); diff --git a/packages/ckeditor5-dev-env/tests/translations/download.js b/packages/ckeditor5-dev-env/tests/translations/download.js index 313b2c1c7..dd7f43ed6 100644 --- a/packages/ckeditor5-dev-env/tests/translations/download.js +++ b/packages/ckeditor5-dev-env/tests/translations/download.js @@ -47,7 +47,7 @@ describe( 'download', () => { } }; - sandbox.stub( process, 'cwd', () => 'workspace' ); + sandbox.stub( process, 'cwd' ).returns( 'workspace' ); mockery.registerMock( 'del', stubs.del ); mockery.registerMock( 'fs-extra', stubs.fs ); @@ -73,7 +73,6 @@ describe( 'download', () => { { slug: 'ckeditor5-ui' }, ]; - // jscs:disable requireCamelCaseOrUpperCaseIdentifiers resourcesDetails = { 'ckeditor5-core': { available_languages: [ { @@ -101,8 +100,6 @@ describe( 'download', () => { 'ckeditor5-ui-en-content': { ui: 'ui' } }; - // jscs:enable requireCamelCaseOrUpperCaseIdentifiers - return download( { token: 'secretToken' } ) .then( () => { sinon.assert.calledOnce( stubs.transifexService.getResources ); diff --git a/packages/ckeditor5-dev-env/tests/translations/transifex-service.js b/packages/ckeditor5-dev-env/tests/translations/transifex-service.js index d96d6e01f..a70786502 100644 --- a/packages/ckeditor5-dev-env/tests/translations/transifex-service.js +++ b/packages/ckeditor5-dev-env/tests/translations/transifex-service.js @@ -25,7 +25,7 @@ describe( 'transifex-service', () => { describe( 'getResources()', () => { it( 'should return resources', () => { const spy = sandbox.spy( ( url, data, cb ) => cb( null, { statusCode: 200 }, '{"body": ""}' ) ); - sandbox.stub( request, 'get', spy ); + sandbox.stub( request, 'get' ).callsFake( spy ); return transifexService.getResources( { token: 'token' @@ -45,47 +45,56 @@ describe( 'transifex-service', () => { it( 'should throw an error if the statusCode is above 300', () => { const spy = sandbox.spy( ( url, data, cb ) => cb( null, { statusCode: 500 }, '{"body": ""}' ) ); - sandbox.stub( request, 'get', spy ); - - return transifexService.getResources( { - token: 'token' - } ) - .then( () => new Error( 'Promise should not be resolved' ) ) - .catch( err => expect( err.message ).to.equal( 'Status code: 500 for \'getResources\' method.' ) ); + sandbox.stub( request, 'get' ).callsFake( spy ); + + return transifexService.getResources( { token: 'token' } ) + .then( + () => { + throw new Error( 'Promise should not be resolved.' ); + }, + err => { + expect( err.message ).to.equal( 'Status code: 500 for \'getResources\' method.' ); + } + ); } ); it( 'should throw an error if some other error occurs', () => { const error = new Error(); const spy = sandbox.spy( ( url, data, cb ) => cb( error, { statusCode: 200 }, '{"body": ""}' ) ); - sandbox.stub( request, 'get', spy ); - - return transifexService.getResources( { - token: 'token' - } ) - .then( () => new Error( 'Promise should not be resolved' ) ) - .catch( err => expect( err ).to.equal( error ) ); + sandbox.stub( request, 'get' ).callsFake( spy ); + + return transifexService.getResources( { token: 'token' } ) + .then( + () => { + throw new Error( 'Promise should not be resolved.' ); + }, + err => { + expect( err ).to.equal( error ); + } + ); } ); it( 'should throw an error if some error occurs during parsing the body', () => { const spy = sandbox.spy( ( url, data, cb ) => cb( null, { statusCode: 200 }, 'Invalid JSON' ) ); - sandbox.stub( request, 'get', spy ); - - return transifexService.getResources( { - token: 'token' - } ) - .then( () => new Error( 'Promise should not be resolved' ) ) - .catch( err => { - expect( err.message ).to.equal( - 'Error handled while parsing body of the \'getResources\' response: Invalid JSON' - ); - } ); + sandbox.stub( request, 'get' ).callsFake( spy ); + + return transifexService.getResources( { token: 'token' } ) + .then( + () => { + throw new Error( 'Promise should not be resolved.' ); + }, + err => { + expect( err.message ).to.equal( + 'Error handled while parsing body of the \'getResources\' response: Invalid JSON' + ); + } ); } ); } ); describe( 'postResource()', () => { it( 'should upload resource on the Transifex', () => { const spy = sandbox.spy( ( url, data, cb ) => cb( null, { statusCode: 201 }, '{"body": ""}' ) ); - sandbox.stub( request, 'post', spy ); + sandbox.stub( request, 'post' ).callsFake( spy ); return transifexService.postResource( { token: 'token', @@ -116,7 +125,7 @@ describe( 'transifex-service', () => { describe( 'putResourceContent()', () => { it( 'should update resource on the Transifex', () => { const spy = sandbox.spy( ( url, data, cb ) => cb( null, { statusCode: 200 }, '{"body": ""}' ) ); - sandbox.stub( request, 'put', spy ); + sandbox.stub( request, 'put' ).callsFake( spy ); return transifexService.putResourceContent( { token: 'token', @@ -144,7 +153,7 @@ describe( 'transifex-service', () => { describe( 'getResourceDetails()', () => { it( 'should get resource details from the Transifex', () => { const spy = sandbox.spy( ( url, data, cb ) => cb( null, { statusCode: 200 }, '{"body": ""}' ) ); - sandbox.stub( request, 'get', spy ); + sandbox.stub( request, 'get' ).callsFake( spy ); return transifexService.getResourceDetails( { token: 'token', @@ -167,7 +176,7 @@ describe( 'transifex-service', () => { describe( 'getTranslation()', () => { it( 'should get translations for the target language of the resource from the Transifex', () => { const spy = sandbox.spy( ( url, data, cb ) => cb( null, { statusCode: 200 }, '{"body": ""}' ) ); - sandbox.stub( request, 'get', spy ); + sandbox.stub( request, 'get' ).callsFake( spy ); return transifexService.getTranslation( { token: 'token', diff --git a/packages/ckeditor5-dev-env/tests/translations/upload.js b/packages/ckeditor5-dev-env/tests/translations/upload.js index 3501f18a2..e2ce06a28 100644 --- a/packages/ckeditor5-dev-env/tests/translations/upload.js +++ b/packages/ckeditor5-dev-env/tests/translations/upload.js @@ -47,7 +47,7 @@ describe( 'upload', () => { logger: () => stubs.logger } ); - sandbox.stub( process, 'cwd', () => path.join( 'workspace', 'ckeditor5' ) ); + sandbox.stub( process, 'cwd' ).returns( path.join( 'workspace', 'ckeditor5' ) ); upload = require( '../../lib/translations/upload' ); } ); From b6745f40e073fd58aa836d55b0e24944e4d10e2f Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Mon, 31 Jul 2017 09:20:53 +0200 Subject: [PATCH 04/11] Upgraded Lerna to stable version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7819c5380..62d424d45 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "gulp": "^3.9.1", "guppy-pre-commit": "^0.4.0", "istanbul": "^0.4.4", - "lerna": "2.0.0-rc.5", + "lerna": "^2.0.0", "mocha": "^3.4.2" }, "engines": { From b019de8262fd6d38ffd68c1fc4b85cd3a0b21226 Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Mon, 31 Jul 2017 11:58:08 +0200 Subject: [PATCH 05/11] Fixed issues with mocks in tests. Some mocks from one test affected to the another one. --- .../ckeditor5-dev-bundler-rollup/package.json | 1 + .../ckeditor5-dev-bundler-rollup/tests/tasks.js | 7 ++++++- .../tests/translations/collect-utils.js | 13 +++---------- .../tests/translations/download.js | 17 +++++++++-------- .../tests/translations/upload.js | 12 +++++++----- .../tests/utils/getgitignore.js | 15 ++++----------- .../tests/translations/translationservice.js | 14 +++----------- 7 files changed, 33 insertions(+), 46 deletions(-) diff --git a/packages/ckeditor5-dev-bundler-rollup/package.json b/packages/ckeditor5-dev-bundler-rollup/package.json index 3cc15c9da..9a36454c1 100644 --- a/packages/ckeditor5-dev-bundler-rollup/package.json +++ b/packages/ckeditor5-dev-bundler-rollup/package.json @@ -29,6 +29,7 @@ "chai": "^4.0.2", "mocha": "^3.4.2", "mockery": "^2.0.0", + "proxyquire": "^1.8.0", "sinon": "^2.3.5" }, "engines": { diff --git a/packages/ckeditor5-dev-bundler-rollup/tests/tasks.js b/packages/ckeditor5-dev-bundler-rollup/tests/tasks.js index 5f2192c21..131d492fb 100644 --- a/packages/ckeditor5-dev-bundler-rollup/tests/tasks.js +++ b/packages/ckeditor5-dev-bundler-rollup/tests/tasks.js @@ -17,6 +17,7 @@ const mockery = require( 'mockery' ); const mkdirp = require( 'mkdirp' ); const fs = require( 'fs' ); const rollup = require( 'rollup' ); +const proxyquire = require( 'proxyquire' ); describe( 'bundle-tasks', () => { let tasks, sandbox; @@ -30,7 +31,11 @@ describe( 'bundle-tasks', () => { mockery.registerMock( 'gulp-cssnano', () => {} ); mockery.registerMock( 'rollup-plugin-babel', config => config ); - tasks = require( '../lib/tasks' ); + tasks = proxyquire( '../lib/tasks', { + '@ckeditor/ckeditor5-dev-utils': { + tools, bundler + } + } ); } ); after( () => { diff --git a/packages/ckeditor5-dev-env/tests/translations/collect-utils.js b/packages/ckeditor5-dev-env/tests/translations/collect-utils.js index fd7888476..d814f1783 100644 --- a/packages/ckeditor5-dev-env/tests/translations/collect-utils.js +++ b/packages/ckeditor5-dev-env/tests/translations/collect-utils.js @@ -8,11 +8,9 @@ const path = require( 'path' ); const { expect } = require( 'chai' ); const sinon = require( 'sinon' ); -const mockery = require( 'mockery' ); const glob = require( 'glob' ); const fs = require( 'fs-extra' ); const proxyquire = require( 'proxyquire' ); -const del = require( 'del' ); describe( 'collect-utils', () => { let sandbox, utils, stubs, originalStringMap; @@ -20,11 +18,6 @@ describe( 'collect-utils', () => { beforeEach( () => { sandbox = sinon.sandbox.create(); - mockery.enable( { - warnOnReplace: false, - warnOnUnregistered: false - } ); - stubs = { logger: { info: sandbox.spy(), @@ -38,19 +31,19 @@ describe( 'collect-utils', () => { }; sandbox.stub( process, 'cwd' ).returns( path.join( 'workspace', 'ckeditor5' ) ); - sandbox.stub( del, 'sync' ).callsFake( stubs.delSync ); utils = proxyquire( '../../lib/translations/collect-utils', { '@ckeditor/ckeditor5-dev-utils': { logger: () => stubs.logger, translations: stubs.translations + }, + del: { + sync: stubs.delSync } } ); } ); afterEach( () => { - mockery.disable(); - mockery.deregisterAll(); sandbox.restore(); } ); diff --git a/packages/ckeditor5-dev-env/tests/translations/download.js b/packages/ckeditor5-dev-env/tests/translations/download.js index dd7f43ed6..ec96b5579 100644 --- a/packages/ckeditor5-dev-env/tests/translations/download.js +++ b/packages/ckeditor5-dev-env/tests/translations/download.js @@ -9,6 +9,7 @@ const sinon = require( 'sinon' ); const path = require( 'path' ); const mockery = require( 'mockery' ); const { expect } = require( 'chai' ); +const proxyquire = require( 'proxyquire' ); describe( 'download', () => { let sandbox, stubs, download, resources, resourcesDetails, translations, fileContents; @@ -49,15 +50,15 @@ describe( 'download', () => { sandbox.stub( process, 'cwd' ).returns( 'workspace' ); - mockery.registerMock( 'del', stubs.del ); - mockery.registerMock( 'fs-extra', stubs.fs ); - mockery.registerMock( '@ckeditor/ckeditor5-dev-utils', { - translations: stubs.translationUtils, - logger: () => stubs.logger + download = proxyquire( '../../lib/translations/download', { + '@ckeditor/ckeditor5-dev-utils': { + translations: stubs.translationUtils, + logger: () => stubs.logger + }, + 'fs-extra': stubs.fs, + 'del': stubs.del, + './transifex-service': stubs.transifexService } ); - mockery.registerMock( './transifex-service', stubs.transifexService ); - - download = require( '../../lib/translations/download' ); } ); afterEach( () => { diff --git a/packages/ckeditor5-dev-env/tests/translations/upload.js b/packages/ckeditor5-dev-env/tests/translations/upload.js index e2ce06a28..5211ee9ea 100644 --- a/packages/ckeditor5-dev-env/tests/translations/upload.js +++ b/packages/ckeditor5-dev-env/tests/translations/upload.js @@ -9,6 +9,7 @@ const path = require( 'path' ); const sinon = require( 'sinon' ); const mockery = require( 'mockery' ); const { expect } = require( 'chai' ); +const proxyquire = require( 'proxyquire' ); describe( 'upload', () => { let sandbox, stubs, upload, packageNames, serverResources, fileContents; @@ -42,14 +43,15 @@ describe( 'upload', () => { }; mockery.registerMock( './transifex-service', stubs.transifexService ); - mockery.registerMock( 'fs', stubs.fs ); - mockery.registerMock( '@ckeditor/ckeditor5-dev-utils', { - logger: () => stubs.logger - } ); sandbox.stub( process, 'cwd' ).returns( path.join( 'workspace', 'ckeditor5' ) ); - upload = require( '../../lib/translations/upload' ); + upload = proxyquire( '../../lib/translations/upload', { + '@ckeditor/ckeditor5-dev-utils': { + logger: () => stubs.logger + }, + 'fs': stubs.fs + } ); } ); afterEach( () => { diff --git a/packages/ckeditor5-dev-lint/tests/utils/getgitignore.js b/packages/ckeditor5-dev-lint/tests/utils/getgitignore.js index c1a1cf6aa..86670d814 100644 --- a/packages/ckeditor5-dev-lint/tests/utils/getgitignore.js +++ b/packages/ckeditor5-dev-lint/tests/utils/getgitignore.js @@ -7,7 +7,7 @@ const sinon = require( 'sinon' ); const expect = require( 'chai' ).expect; -const mockery = require( 'mockery' ); +const proxyquire = require( 'proxyquire' ); describe( 'dev-lint/utils', () => { let getGitIgnore, sandbox, stubs; @@ -15,26 +15,19 @@ describe( 'dev-lint/utils', () => { beforeEach( () => { sandbox = sinon.sandbox.create(); - mockery.enable( { - useCleanCache: true, - warnOnReplace: false, - warnOnUnregistered: false - } ); - stubs = { fs: { readFileSync: sandbox.stub() } }; - mockery.registerMock( 'fs', stubs.fs ); - - getGitIgnore = require( '../../lib/utils/getgitignore' ); + getGitIgnore = proxyquire( '../../lib/utils/getgitignore', { + fs: stubs.fs + } ); } ); afterEach( () => { sandbox.restore(); - mockery.disable(); } ); describe( 'getGitIgnore()', () => { diff --git a/packages/ckeditor5-dev-utils/tests/translations/translationservice.js b/packages/ckeditor5-dev-utils/tests/translations/translationservice.js index 151e61388..06972a069 100644 --- a/packages/ckeditor5-dev-utils/tests/translations/translationservice.js +++ b/packages/ckeditor5-dev-utils/tests/translations/translationservice.js @@ -10,19 +10,13 @@ const sinon = require( 'sinon' ); const expect = chai.expect; const path = require( 'path' ); const proxyquire = require( 'proxyquire' ); -const mockery = require( 'mockery' ); describe( 'translations', () => { describe( 'TranslationService', () => { - const sandbox = sinon.sandbox.create(); - let TranslationService, stubs, files, fileContents; + let TranslationService, stubs, files, fileContents, sandbox; beforeEach( () => { - mockery.enable( { - useCleanCache: true, - warnOnReplace: false, - warnOnUnregistered: false - } ); + sandbox = sinon.sandbox.create(); stubs = { logger: { @@ -36,16 +30,14 @@ describe( 'translations', () => { } }; - mockery.registerMock( 'fs', stubs.fs ); - TranslationService = proxyquire( '../../lib/translations/translationservice', { '../logger': () => stubs.logger, + 'fs': stubs.fs } ); } ); afterEach( () => { sandbox.restore(); - mockery.disable(); } ); describe( 'constructor()', () => { From f400a561df8b87019b18ed97425a656dc54b53c9 Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Mon, 31 Jul 2017 12:17:26 +0200 Subject: [PATCH 06/11] Code style fixes. --- .../lib/translations/collect-utils.js | 29 ++++++++++--------- .../utils/manual-tests/compilescripts.js | 3 +- .../lib/bundler/getlicensebanner.js | 2 ++ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/ckeditor5-dev-env/lib/translations/collect-utils.js b/packages/ckeditor5-dev-env/lib/translations/collect-utils.js index 971c9f80b..d88e21347 100644 --- a/packages/ckeditor5-dev-env/lib/translations/collect-utils.js +++ b/packages/ckeditor5-dev-env/lib/translations/collect-utils.js @@ -165,20 +165,21 @@ const utils = { _getTranslationCallsFromFile( filePath, fileContent ) { const originalStrings = findOriginalStrings( fileContent ); - return originalStrings.map( originalString => { - const contextMatch = originalString.match( /\[context: ([^\]]+)\]/ ); - const sentenceMatch = originalString.match( /^[^[]+/ ); - const packageMatch = filePath.match( /\/(ckeditor5-[^/]+)\// ); - - return { - filePath, - key: originalString, - package: packageMatch[ 1 ], - context: contextMatch ? contextMatch[ 1 ] : null, - sentence: sentenceMatch[ 0 ].trim(), - }; - } ) - .filter( translationCall => !!translationCall ); + return originalStrings + .map( originalString => { + const contextMatch = originalString.match( /\[context: ([^\]]+)\]/ ); + const sentenceMatch = originalString.match( /^[^[]+/ ); + const packageMatch = filePath.match( /\/(ckeditor5-[^/]+)\// ); + + return { + filePath, + key: originalString, + package: packageMatch[ 1 ], + context: contextMatch ? contextMatch[ 1 ] : null, + sentence: sentenceMatch[ 0 ].trim(), + }; + } ) + .filter( translationCall => !!translationCall ); }, _stringifyTranslationObjects( translationObjects ) { diff --git a/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilescripts.js b/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilescripts.js index 5d67dd696..ad297c425 100644 --- a/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilescripts.js +++ b/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilescripts.js @@ -105,8 +105,7 @@ describe( 'compileManualTestScripts', () => { expect( stubs.getRelativeFilePath.secondCall.args[ 0 ] ) .to.equal( 'ckeditor5-build-classic/tests/manual/ckeditor.compcat.js' ); expect( stubs.getRelativeFilePath.thirdCall.args[ 0 ] ) - .to.equal( 'ckeditor5-editor-classic/tests/manual/classic.js' - ); + .to.equal( 'ckeditor5-editor-classic/tests/manual/classic.js' ); } ); } ); diff --git a/packages/ckeditor5-dev-utils/lib/bundler/getlicensebanner.js b/packages/ckeditor5-dev-utils/lib/bundler/getlicensebanner.js index ca8354bfc..0d165d07c 100644 --- a/packages/ckeditor5-dev-utils/lib/bundler/getlicensebanner.js +++ b/packages/ckeditor5-dev-utils/lib/bundler/getlicensebanner.js @@ -8,10 +8,12 @@ module.exports = function getLicenseBanner() { const date = new Date(); + /* eslint-disable indent */ return ( `/** * @license Copyright (c) 2003-${ date.getFullYear() }, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md. */` ); + /* eslint-enable indent */ }; From ca7ec2f1964cab2265b4c7215ffdb461ad6aeef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Koszuli=C5=84ski?= Date: Fri, 4 Aug 2017 16:21:57 +0200 Subject: [PATCH 07/11] Update remaining packages. --- packages/ckeditor5-dev-tests/package.json | 6 ++---- packages/jsdoc-plugins/package.json | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/ckeditor5-dev-tests/package.json b/packages/ckeditor5-dev-tests/package.json index 29c395d3c..2d2abe866 100644 --- a/packages/ckeditor5-dev-tests/package.json +++ b/packages/ckeditor5-dev-tests/package.json @@ -38,14 +38,12 @@ "node-sass": "^4.5.3", "raw-loader": "^0.5.1", "sass-loader": "^6.0.6", - "sinon": "^1.17.6", + "sinon": "^2.3.5", "style-loader": "^0.18.2", "webpack": "^3.0.0" }, "devDependencies": { - "chai": "^4.0.2", - "mockery": "^2.0.0", - "sinon": "^2.3.5" + "mockery": "^2.0.0" }, "engines": { "node": ">=6.0.0", diff --git a/packages/jsdoc-plugins/package.json b/packages/jsdoc-plugins/package.json index 6112873f7..eaed75313 100644 --- a/packages/jsdoc-plugins/package.json +++ b/packages/jsdoc-plugins/package.json @@ -4,11 +4,11 @@ "description": "Various JSDoc plugins developed by the CKEditor 5 team.", "keywords": [], "dependencies": { - "fs-extra": "^2.0.0", + "fs-extra": "^3.0.1", "lodash": "^4.17.4" }, "devDependencies": { - "chai": "^3.5.0" + "chai": "^4.0.2" }, "engines": { "node": ">=6.0.0", From eb50099cbe708108dd7c455f78b8a3d006fc2e1c Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Mon, 7 Aug 2017 09:48:22 +0200 Subject: [PATCH 08/11] Fixed sinon warnings. --- packages/ckeditor5-dev-tests/tests/tasks/runmanualtests.js | 4 ++-- .../tests/utils/automated-tests/getkarmaconfig.js | 6 +++--- .../tests/utils/manual-tests/compilehtmlfiles.js | 6 +++--- .../tests/utils/manual-tests/compilescripts.js | 2 +- .../tests/utils/transformfileoptiontotestglob.js | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/ckeditor5-dev-tests/tests/tasks/runmanualtests.js b/packages/ckeditor5-dev-tests/tests/tasks/runmanualtests.js index a9a81dfb4..e56876489 100644 --- a/packages/ckeditor5-dev-tests/tests/tasks/runmanualtests.js +++ b/packages/ckeditor5-dev-tests/tests/tasks/runmanualtests.js @@ -36,8 +36,8 @@ describe( 'runManualTests', () => { mockery.registerMock( '../utils/manual-tests/removedir', spies.removeDir ); mockery.registerMock( '../utils/transformfileoptiontotestglob', spies.transformFileOptionToTestGlob ); - sandbox.stub( path, 'join', ( ...chunks ) => chunks.join( '/' ) ); - sandbox.stub( process, 'cwd', () => 'workspace' ); + sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) ); + sandbox.stub( process, 'cwd' ).returns( 'workspace' ); runManualTests = require( '../../lib/tasks/runmanualtests' ); } ); diff --git a/packages/ckeditor5-dev-tests/tests/utils/automated-tests/getkarmaconfig.js b/packages/ckeditor5-dev-tests/tests/utils/automated-tests/getkarmaconfig.js index 560994441..68b877169 100644 --- a/packages/ckeditor5-dev-tests/tests/utils/automated-tests/getkarmaconfig.js +++ b/packages/ckeditor5-dev-tests/tests/utils/automated-tests/getkarmaconfig.js @@ -16,12 +16,12 @@ describe( 'getKarmaConfig', () => { beforeEach( () => { sandbox = sinon.sandbox.create(); - sandbox.stub( process, 'cwd', () => 'workspace' ); + sandbox.stub( process, 'cwd' ).returns( 'workspace' ); // sinon cannot stub non-existing props. process.env = Object.assign( {}, originalEnv, { TRAVIS: false } ); - sandbox.stub( path, 'join', ( ...chunks ) => chunks.join( '/' ) ); - sandbox.stub( path, 'sep', '/' ); + sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) ); + sandbox.stub( path, 'sep' ).value( '/' ); mockery.enable( { warnOnReplace: false, diff --git a/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilehtmlfiles.js b/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilehtmlfiles.js index ff12be14f..934d15f73 100644 --- a/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilehtmlfiles.js +++ b/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilehtmlfiles.js @@ -35,7 +35,7 @@ describe( 'compileHtmlFiles', () => { }, path: { - join: sandbox.stub( path, 'join', ( ...chunks ) => chunks.join( '/' ) ) + join: sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) ) }, logger: { @@ -50,13 +50,13 @@ describe( 'compileHtmlFiles', () => { }, gutil: { - colors: sandbox.stub( gutil, 'colors', { + colors: sandbox.stub( gutil, 'colors' ).value( { cyan: text => text } ) }, chokidar: { - watch: sandbox.stub( chokidar, 'watch', () => ( { + watch: sandbox.stub( chokidar, 'watch' ).callsFake( () => ( { on: () => { } } ) ) diff --git a/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilescripts.js b/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilescripts.js index ad297c425..8665061a0 100644 --- a/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilescripts.js +++ b/packages/ckeditor5-dev-tests/tests/utils/manual-tests/compilescripts.js @@ -34,7 +34,7 @@ describe( 'compileManualTestScripts', () => { buildDir } ) ), getRelativeFilePath: sandbox.spy( x => x ), - pathJoin: sandbox.stub( path, 'join', ( ...chunks ) => chunks.join( '/' ) ) + pathJoin: sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) ) }; mockery.registerMock( '../glob', stubs.glob ); diff --git a/packages/ckeditor5-dev-tests/tests/utils/transformfileoptiontotestglob.js b/packages/ckeditor5-dev-tests/tests/utils/transformfileoptiontotestglob.js index 7681b6e82..37831a75b 100644 --- a/packages/ckeditor5-dev-tests/tests/utils/transformfileoptiontotestglob.js +++ b/packages/ckeditor5-dev-tests/tests/utils/transformfileoptiontotestglob.js @@ -17,7 +17,7 @@ describe( 'dev-tests/utils', () => { transformFileOptionToTestGlob = require( '../../lib/utils/transformfileoptiontotestglob' ); - sandbox.stub( path, 'join', ( ...chunks ) => chunks.join( '/' ) ); + sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) ); sandbox.stub( process, 'cwd' ).returns( '/workspace' ); } ); From efd871381d4979dd0e3011bc1002c59c22e2a32d Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Mon, 7 Aug 2017 14:33:13 +0200 Subject: [PATCH 09/11] Fixed Linter errors. --- .../tests/release-tools/tasks/releasesubrepositories.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ckeditor5-dev-env/tests/release-tools/tasks/releasesubrepositories.js b/packages/ckeditor5-dev-env/tests/release-tools/tasks/releasesubrepositories.js index 68ae7ee1a..8052aec9b 100644 --- a/packages/ckeditor5-dev-env/tests/release-tools/tasks/releasesubrepositories.js +++ b/packages/ckeditor5-dev-env/tests/release-tools/tasks/releasesubrepositories.js @@ -34,7 +34,7 @@ const filesToRecoverAfterTest = [ ]; describe( 'dev-env/release-tools/tasks', function() { - this.timeout( 10 * 1000 ); // 10 sec * 1000 ms + this.timeout( 10 * 1000 ); // 10 sec * 1000 ms let releaseSubRepositories, sandbox, stubs; From 4d90c84b9f647841df94375f8d741d91071b6af0 Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Tue, 8 Aug 2017 08:29:47 +0200 Subject: [PATCH 10/11] Simplified the mocks. --- .../tests/utils.js | 16 +++++++--------- packages/ckeditor5-dev-utils/tests/tools.js | 18 ++++++++---------- .../ckeditor5-dev-utils/tests/workspace.js | 18 +++++++++--------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/packages/ckeditor5-dev-bundler-rollup/tests/utils.js b/packages/ckeditor5-dev-bundler-rollup/tests/utils.js index 58f6f21d8..496086153 100644 --- a/packages/ckeditor5-dev-bundler-rollup/tests/utils.js +++ b/packages/ckeditor5-dev-bundler-rollup/tests/utils.js @@ -27,7 +27,7 @@ describe( 'bundle-utils', () => { describe( 'maybeCleanDir()', () => { it( 'should clean directory if dir is provided', () => { - const cleanStub = sandbox.stub( tools, 'clean' ).callsFake( () => Promise.resolve() ); + const cleanStub = sandbox.stub( tools, 'clean' ).resolves(); sandbox.stub( path, 'join' ).callsFake( x => x ); const promise = utils.maybeCleanDir( 'dir' ); @@ -37,7 +37,7 @@ describe( 'bundle-utils', () => { } ); it( 'should return resolved promise if no dir is provided', () => { - const cleanStub = sandbox.stub( tools, 'clean' ).callsFake( () => Promise.resolve() ); + const cleanStub = sandbox.stub( tools, 'clean' ).resolves(); sandbox.stub( path, 'join' ).callsFake( x => x ); const promise = utils.maybeCleanDir(); @@ -64,9 +64,7 @@ describe( 'bundle-utils', () => { it( 'should return file size in bytes', () => { const filePath = 'path/to/file'; const size = 1337; - const statSyncMock = sandbox.stub( fs, 'statSync' ).callsFake( () => { - return { size }; - } ); + const statSyncMock = sandbox.stub( fs, 'statSync' ).returns( { size } ); expect( utils.getFileSize( filePath ) ).to.be.equal( size ); sinon.assert.calledWithExactly( statSyncMock, filePath ); @@ -78,8 +76,8 @@ describe( 'bundle-utils', () => { const filePath = 'path/to/file'; const size = 1337; const fileContent = 'some string'; - const readFileSyncMock = sandbox.stub( fs, 'readFileSync' ).callsFake( () => fileContent ); - const gzipSizeMock = sandbox.stub( gzipSize, 'sync' ).callsFake( () => 1337 ); + const readFileSyncMock = sandbox.stub( fs, 'readFileSync' ).returns( fileContent ); + const gzipSizeMock = sandbox.stub( gzipSize, 'sync' ).returns( 1337 ); expect( utils.getGzippedFileSize( filePath ) ).to.be.equal( size ); sinon.assert.calledWithExactly( readFileSyncMock, filePath ); @@ -94,8 +92,8 @@ describe( 'bundle-utils', () => { size = 1337; gzippedSize = 543; - sandbox.stub( utils, 'getFileSize' ).callsFake( () => size ); - sandbox.stub( utils, 'getGzippedFileSize' ).callsFake( () => gzippedSize ); + sandbox.stub( utils, 'getFileSize' ).returns( size ); + sandbox.stub( utils, 'getGzippedFileSize' ).returns( gzippedSize ); } ); it( 'should returns an array with two elements', () => { diff --git a/packages/ckeditor5-dev-utils/tests/tools.js b/packages/ckeditor5-dev-utils/tests/tools.js index d407457b4..41601cc59 100644 --- a/packages/ckeditor5-dev-utils/tests/tools.js +++ b/packages/ckeditor5-dev-utils/tests/tools.js @@ -174,7 +174,7 @@ describe( 'utils', () => { it( 'should get directories in specified path', () => { const fs = require( 'fs' ); const directories = [ 'dir1', 'dir2', 'dir3' ]; - const readdirSyncStub = sandbox.stub( fs, 'readdirSync' ).callsFake( () => directories ); + const readdirSyncStub = sandbox.stub( fs, 'readdirSync' ).returns( directories ); const isDirectoryStub = sandbox.stub( tools, 'isDirectory' ).returns( true ); const dirPath = 'path'; @@ -193,7 +193,7 @@ describe( 'utils', () => { it( 'should return true if path points to directory', () => { const fs = require( 'fs' ); - const statSyncStub = sandbox.stub( fs, 'statSync' ).callsFake( () => ( { isDirectory: () => true } ) ); + const statSyncStub = sandbox.stub( fs, 'statSync' ).returns( { isDirectory: () => true } ); const path = 'path'; const result = tools.isDirectory( path ); @@ -205,7 +205,7 @@ describe( 'utils', () => { it( 'should return false if path does not point to directory', () => { const fs = require( 'fs' ); - const statSyncStub = sandbox.stub( fs, 'statSync' ).callsFake( () => ( { isDirectory: () => false } ) ); + const statSyncStub = sandbox.stub( fs, 'statSync' ).returns( { isDirectory: () => false } ); const path = 'path'; const result = tools.isDirectory( path ); @@ -233,7 +233,7 @@ describe( 'utils', () => { it( 'should return true if path points to file', () => { const fs = require( 'fs' ); - const statSyncStub = sandbox.stub( fs, 'statSync' ).callsFake( () => ( { isFile: () => true } ) ); + const statSyncStub = sandbox.stub( fs, 'statSync' ).returns( { isFile: () => true } ); const path = 'path'; const result = tools.isFile( path ); @@ -245,7 +245,7 @@ describe( 'utils', () => { it( 'should return false if path does not point to directory', () => { const fs = require( 'fs' ); - const statSyncStub = sandbox.stub( fs, 'statSync' ).callsFake( () => ( { isFile: () => false } ) ); + const statSyncStub = sandbox.stub( fs, 'statSync' ).returns( { isFile: () => false } ); const path = 'path'; const result = tools.isFile( path ); @@ -293,7 +293,7 @@ describe( 'utils', () => { it( 'should read, update and save JSON file', () => { const path = 'path/to/file.json'; const fs = require( 'fs' ); - const readFileStub = sandbox.stub( fs, 'readFileSync' ).callsFake( () => '{}' ); + const readFileStub = sandbox.stub( fs, 'readFileSync' ).returns( '{}' ); const modifiedJSON = { modified: true }; const writeFileStub = sandbox.stub( fs, 'writeFileSync' ); @@ -350,7 +350,7 @@ describe( 'utils', () => { it( 'should return null if no name in package.json is provided', () => { sandbox.stub( tools, 'isFile' ).returns( true ); const fs = require( 'fs' ); - sandbox.stub( fs, 'readFileSync' ).returns( JSON.stringify( { } ) ); + sandbox.stub( fs, 'readFileSync' ).returns( JSON.stringify( {} ) ); const result = tools.readPackageName( modulePath ); @@ -450,9 +450,7 @@ describe( 'utils', () => { it( 'should be defined', () => expect( tools.getGitUrlFromNpm ).to.be.a( 'function' ) ); it( 'should call npm view command', () => { - const shExecStub = sandbox.stub( tools, 'shExec' ).callsFake( () => { - return JSON.stringify( repository ); - } ); + const shExecStub = sandbox.stub( tools, 'shExec' ).returns( JSON.stringify( repository ) ); const url = tools.getGitUrlFromNpm( moduleName ); expect( shExecStub.calledOnce ).to.equal( true ); diff --git a/packages/ckeditor5-dev-utils/tests/workspace.js b/packages/ckeditor5-dev-utils/tests/workspace.js index 24cfb254f..5d38753e1 100644 --- a/packages/ckeditor5-dev-utils/tests/workspace.js +++ b/packages/ckeditor5-dev-utils/tests/workspace.js @@ -60,7 +60,7 @@ describe( 'utils', () => { it( 'should return only ckeditor5 directories', () => { const workspacePath = '/workspace/path'; const sourceDirectories = [ 'tools', 'ckeditor5', 'ckeditor5-core', '.bin', 'ckeditor5-plugin-image' ]; - sandbox.stub( tools, 'getDirectories' ).callsFake( () => sourceDirectories ); + sandbox.stub( tools, 'getDirectories' ).returns( sourceDirectories ); const directories = ckeditor5Dirs.getDirectories( workspacePath ); expect( directories.length ).to.equal( 2 ); @@ -103,8 +103,8 @@ describe( 'utils', () => { it( 'should return empty array if no dev directories were found - because of missing ckeditor5-* repos', () => { const wrongRepositoryInfo = { name: 'plugins/plugin' }; - sandbox.stub( ckeditor5Dirs, 'getDirectories' ).callsFake( () => sourceDirectories ); - sandbox.stub( ckeditor5Dirs, 'getDependencies' ).callsFake( () => dependencies ); + sandbox.stub( ckeditor5Dirs, 'getDirectories' ).returns( sourceDirectories ); + sandbox.stub( ckeditor5Dirs, 'getDependencies' ).returns( dependencies ); sandbox.stub( git, 'parseRepositoryUrl' ).returns( wrongRepositoryInfo ); const directories = ckeditor5Dirs.getDevDirectories( workspacePath, packageJSONDependencies, ckeditor5Path ); @@ -116,8 +116,8 @@ describe( 'utils', () => { it( 'should return empty array if no dev directories were found - because of missing ckeditor5-* dirs', () => { const wrongDirectories = [ 'tools', 'ckeditor5', '.bin' ]; - sandbox.stub( ckeditor5Dirs, 'getDirectories' ).callsFake( () => wrongDirectories ); - sandbox.stub( ckeditor5Dirs, 'getDependencies' ).callsFake( () => dependencies ); + sandbox.stub( ckeditor5Dirs, 'getDirectories' ).returns( wrongDirectories ); + sandbox.stub( ckeditor5Dirs, 'getDependencies' ).returns( dependencies ); sandbox.stub( git, 'parseRepositoryUrl' ).returns( repositoryInfo ); const directories = ckeditor5Dirs.getDevDirectories( workspacePath, packageJSONDependencies, ckeditor5Path ); @@ -127,8 +127,8 @@ describe( 'utils', () => { } ); it( 'should return only ckeditor5 directories in development mode', () => { - sandbox.stub( ckeditor5Dirs, 'getDirectories' ).callsFake( () => sourceDirectories ); - sandbox.stub( ckeditor5Dirs, 'getDependencies' ).callsFake( () => dependencies ); + sandbox.stub( ckeditor5Dirs, 'getDirectories' ).returns( sourceDirectories ); + sandbox.stub( ckeditor5Dirs, 'getDependencies' ).returns( dependencies ); sandbox.stub( git, 'parseRepositoryUrl' ).returns( repositoryInfo ); const directories = ckeditor5Dirs.getDevDirectories( workspacePath, packageJSONDependencies, ckeditor5Path ); @@ -145,8 +145,8 @@ describe( 'utils', () => { } ); it( 'should return only ckeditor5 directories in development mode, including root directory', () => { - sandbox.stub( ckeditor5Dirs, 'getDirectories' ).callsFake( () => sourceDirectories ); - sandbox.stub( ckeditor5Dirs, 'getDependencies' ).callsFake( () => dependencies ); + sandbox.stub( ckeditor5Dirs, 'getDirectories' ).returns( sourceDirectories ); + sandbox.stub( ckeditor5Dirs, 'getDependencies' ).returns( dependencies ); sandbox.stub( git, 'parseRepositoryUrl' ).returns( repositoryInfo ); const includeRoot = true; From dcecdb4e2d69318fc2e872c8edefac870146ae57 Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Tue, 8 Aug 2017 11:50:21 +0200 Subject: [PATCH 11/11] Upgraded Sinon to the latest (3.1.0) version. --- packages/ckeditor5-dev-bundler-rollup/package.json | 2 +- packages/ckeditor5-dev-env/package.json | 2 +- packages/ckeditor5-dev-lint/package.json | 2 +- packages/ckeditor5-dev-tests/package.json | 2 +- packages/ckeditor5-dev-utils/package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/ckeditor5-dev-bundler-rollup/package.json b/packages/ckeditor5-dev-bundler-rollup/package.json index 9a36454c1..d50d5f845 100644 --- a/packages/ckeditor5-dev-bundler-rollup/package.json +++ b/packages/ckeditor5-dev-bundler-rollup/package.json @@ -30,7 +30,7 @@ "mocha": "^3.4.2", "mockery": "^2.0.0", "proxyquire": "^1.8.0", - "sinon": "^2.3.5" + "sinon": "^3.1.0" }, "engines": { "node": ">=6.0.0", diff --git a/packages/ckeditor5-dev-env/package.json b/packages/ckeditor5-dev-env/package.json index 76011e0b3..da3defcf0 100644 --- a/packages/ckeditor5-dev-env/package.json +++ b/packages/ckeditor5-dev-env/package.json @@ -28,7 +28,7 @@ "handlebars": "^4.0.10", "mockery": "^2.0.0", "proxyquire": "^1.8.0", - "sinon": "^2.3.5" + "sinon": "^3.1.0" }, "engines": { "node": ">=6.0.0", diff --git a/packages/ckeditor5-dev-lint/package.json b/packages/ckeditor5-dev-lint/package.json index 97d4f9b03..20ba83f09 100644 --- a/packages/ckeditor5-dev-lint/package.json +++ b/packages/ckeditor5-dev-lint/package.json @@ -15,7 +15,7 @@ "chai": "^4.0.2", "guppy-pre-commit": "^0.4.0", "mockery": "^2.0.0", - "sinon": "^2.3.5", + "sinon": "^3.1.0", "through2": "^2.0.3", "vinyl": "^2.0.2" }, diff --git a/packages/ckeditor5-dev-tests/package.json b/packages/ckeditor5-dev-tests/package.json index 2d2abe866..da72614ae 100644 --- a/packages/ckeditor5-dev-tests/package.json +++ b/packages/ckeditor5-dev-tests/package.json @@ -38,7 +38,7 @@ "node-sass": "^4.5.3", "raw-loader": "^0.5.1", "sass-loader": "^6.0.6", - "sinon": "^2.3.5", + "sinon": "^3.1.0", "style-loader": "^0.18.2", "webpack": "^3.0.0" }, diff --git a/packages/ckeditor5-dev-utils/package.json b/packages/ckeditor5-dev-utils/package.json index c92920ed0..8cd0a540f 100644 --- a/packages/ckeditor5-dev-utils/package.json +++ b/packages/ckeditor5-dev-utils/package.json @@ -18,7 +18,7 @@ "devDependencies": { "chai": "^4.0.2", "mockery": "^2.0.0", - "sinon": "^2.3.5", + "sinon": "^3.1.0", "vinyl": "^2.0.2" }, "engines": {