8
0
Szymon Kupś 10 лет назад
Родитель
Сommit
32852e53a4
1 измененных файлов с 34 добавлено и 0 удалено
  1. 34 0
      dev/tests/tools.js

+ 34 - 0
dev/tests/tools.js

@@ -23,6 +23,31 @@ describe( 'utils', () => {
 	} );
 
 	describe( 'tools', () => {
+		describe( 'shExec', () => {
+			it( 'should be defined', () => expect( tools.shExec ).to.be.a( 'function' ) );
+
+			it( 'should execute command', () => {
+				const sh = require( 'shelljs' );
+				const execStub = sinon.stub( sh, 'exec' ).returns( { code: 0 } );
+				toRestore.push( execStub );
+
+				tools.shExec( 'command' );
+
+				sinon.assert.calledOnce( execStub );
+			} );
+
+			it( 'should throw error on unsuccessful call', () => {
+				const sh = require( 'shelljs' );
+				const execStub = sinon.stub( sh, 'exec' ).returns( { code: 1 } );
+				toRestore.push( execStub );
+
+				expect( () => {
+					tools.shExec( 'command' );
+				} ).to.throw();
+				sinon.assert.calledOnce( execStub );
+			} );
+		} );
+
 		describe( 'linkDirectories', () => {
 			it( 'should be defined', () => expect( tools.linkDirectories ).to.be.a( 'function' ) );
 
@@ -68,6 +93,7 @@ describe( 'utils', () => {
 					'plugin3': ''
 				};
 				expect( tools.getCKEditorDependencies( dependencies ) ).to.equal( null );
+				expect( tools.getCKEditorDependencies() ).to.equal( null );
 			} );
 
 			it( 'should return only ckeditor5- dependencies', () => {
@@ -262,6 +288,14 @@ describe( 'utils', () => {
 				expect( url ).to.equal( null );
 			} );
 
+			it( 'should return null if module has no repository information', () => {
+				const shExecStub = sinon.stub( tools, 'shExec' ).returns( JSON.stringify( {} ) );
+				toRestore.push( shExecStub );
+
+				const url = tools.getGitUrlFromNpm( moduleName );
+				expect( url ).to.equal( null );
+			} );
+
 			it( 'should throw on other errors', () => {
 				const error = new Error( 'Random error.' );
 				const shExecStub = sinon.stub( tools, 'shExec' ).throws( error );