|
|
@@ -10,8 +10,10 @@
|
|
|
const chai = require( 'chai' );
|
|
|
const sinon = require( 'sinon' );
|
|
|
const expect = chai.expect;
|
|
|
+const path = require( 'path' );
|
|
|
const ckeditor5Dirs = require( '../../utils/ckeditor5-dirs' );
|
|
|
const tools = require( '../../utils/tools' );
|
|
|
+const git = require( '../../utils/git' );
|
|
|
let sandbox;
|
|
|
|
|
|
describe( 'utils', () => {
|
|
|
@@ -28,23 +30,23 @@ describe( 'utils', () => {
|
|
|
it( 'should be defined', () => expect( ckeditor5Dirs.getDependencies ).to.be.a( 'function' ) );
|
|
|
|
|
|
it( 'should return null if no CKEditor5 repository is found', () => {
|
|
|
- const dependencies = {
|
|
|
+ const packageJSONDependencies = {
|
|
|
'plugin1': '',
|
|
|
'plugin2': '',
|
|
|
'plugin3': ''
|
|
|
};
|
|
|
- expect( ckeditor5Dirs.getDependencies( dependencies ) ).to.equal( null );
|
|
|
+ expect( ckeditor5Dirs.getDependencies( packageJSONDependencies ) ).to.equal( null );
|
|
|
expect( ckeditor5Dirs.getDependencies() ).to.equal( null );
|
|
|
} );
|
|
|
|
|
|
it( 'should return only ckeditor5- dependencies', () => {
|
|
|
- const dependencies = {
|
|
|
+ const packageJSONDependencies = {
|
|
|
'plugin1': '',
|
|
|
'ckeditor5-plugin-image': 'ckeditor/ckeditor5-plugin-image',
|
|
|
'plugin2': '',
|
|
|
'ckeditor5-core': 'ckeditor/ckeditor5-core'
|
|
|
};
|
|
|
- const ckeditorDependencies = ckeditor5Dirs.getDependencies( dependencies );
|
|
|
+ const ckeditorDependencies = ckeditor5Dirs.getDependencies( packageJSONDependencies );
|
|
|
|
|
|
expect( ckeditorDependencies ).to.be.an( 'object' );
|
|
|
expect( ckeditorDependencies.plugin1 ).to.be.a( 'undefined' );
|
|
|
@@ -82,5 +84,63 @@ describe( 'utils', () => {
|
|
|
expect( symlinks[ 1 ] ).to.equal( 'ckeditor5-image' );
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ describe( 'getDevDirectories', () => {
|
|
|
+ const packageJSONDependencies = {};
|
|
|
+ const workspacePath = '/workspace/path';
|
|
|
+ const ckeditor5Path = path.join( workspacePath, 'ckeditor5' );
|
|
|
+ const dependencies = {
|
|
|
+ 'ckeditor5-plugin-image': 'ckeditor/ckeditor5-plugin-image',
|
|
|
+ 'ckeditor5-core': 'ckeditor/ckeditor5-core'
|
|
|
+ };
|
|
|
+ const sourceDirectories = [ 'tools', 'ckeditor5', 'ckeditor5-core', '.bin', 'ckeditor5-plugin-image' ];
|
|
|
+ const repositoryInfo = { name: 'ckeditor5-core' };
|
|
|
+
|
|
|
+ it( 'should be defined', () => expect( ckeditor5Dirs.getDevDirectories ).to.be.a( 'function' ) );
|
|
|
+
|
|
|
+ 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( git, 'parseRepositoryUrl' ).returns( wrongRepositoryInfo );
|
|
|
+
|
|
|
+ const directories = ckeditor5Dirs.getDevDirectories( workspacePath, packageJSONDependencies, ckeditor5Path );
|
|
|
+
|
|
|
+ expect( directories ).to.be.a( 'array' );
|
|
|
+ expect( directories.length ).to.equal( 0 );
|
|
|
+ } );
|
|
|
+
|
|
|
+ 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( git, 'parseRepositoryUrl' ).returns( repositoryInfo );
|
|
|
+
|
|
|
+ const directories = ckeditor5Dirs.getDevDirectories( workspacePath, packageJSONDependencies, ckeditor5Path );
|
|
|
+
|
|
|
+ expect( directories ).to.be.a( 'array' );
|
|
|
+ expect( directories.length ).to.equal( 0 );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should return only ckeditor5 directories in development mode', () => {
|
|
|
+ sandbox.stub( ckeditor5Dirs, 'getDirectories', () => sourceDirectories );
|
|
|
+ sandbox.stub( ckeditor5Dirs, 'getDependencies', () => dependencies );
|
|
|
+ sandbox.stub( git, 'parseRepositoryUrl' ).returns( repositoryInfo );
|
|
|
+
|
|
|
+ const directories = ckeditor5Dirs.getDevDirectories( workspacePath, packageJSONDependencies, ckeditor5Path );
|
|
|
+
|
|
|
+ expect( directories.length ).equal( 2 );
|
|
|
+ expect( directories[ 0 ] ).eql( {
|
|
|
+ repositoryURL: 'ckeditor/ckeditor5-plugin-image',
|
|
|
+ repositoryPath: '/workspace/path/ckeditor5/node_modules/ckeditor5-plugin-image'
|
|
|
+ } );
|
|
|
+ expect( directories[ 1 ] ).eql( {
|
|
|
+ repositoryURL: 'ckeditor/ckeditor5-core',
|
|
|
+ repositoryPath: '/workspace/path/ckeditor5/node_modules/ckeditor5-core'
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|
|
|
} );
|