init.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* global describe, it */
  6. 'use strict';
  7. const sinon = require( 'sinon' );
  8. const tools = require( '../../utils/tools' );
  9. describe( 'dev-init', () => {
  10. const initTask = require( '../../tasks/dev/tasks/init' );
  11. const ckeditor5Path = 'path/to/ckeditor5';
  12. const workspaceRoot = '..';
  13. it( 'should get all ckedtior5- dependencies and execute dev-install on them', () => {
  14. const getDependenciesSpy = sinon.spy( tools, 'getCKEditorDependencies' );
  15. const installSpy = sinon.spy();
  16. const JSON = {
  17. dependencies: {
  18. 'ckeditor5-core': 'ckeditor/ckeditor5-code',
  19. 'non-ckeditor-plugin': '^2.0.0',
  20. 'ckeditor5-plugin-devtest': 'ckeditor/ckeditor5-plugin-devtest'
  21. }
  22. };
  23. const deps = JSON.dependencies;
  24. initTask( installSpy, ckeditor5Path, JSON, workspaceRoot );
  25. getDependenciesSpy.restore();
  26. sinon.assert.calledOnce( getDependenciesSpy );
  27. sinon.assert.calledWithExactly( getDependenciesSpy, deps );
  28. sinon.assert.calledTwice( installSpy );
  29. sinon.assert.calledWithExactly( installSpy.firstCall, ckeditor5Path, workspaceRoot, deps[ 'ckeditor5-core' ] );
  30. sinon.assert.calledWithExactly( installSpy.secondCall, ckeditor5Path, workspaceRoot, deps[ 'ckeditor5-plugin-devtest' ] );
  31. } );
  32. it( 'should not call dev-install if no ckedtior5- dependencies', () => {
  33. const getDependenciesSpy = sinon.spy( tools, 'getCKEditorDependencies' );
  34. const installSpy = sinon.spy();
  35. const JSON = {
  36. dependencies: {}
  37. };
  38. initTask( installSpy, ckeditor5Path, JSON, workspaceRoot );
  39. getDependenciesSpy.restore();
  40. sinon.assert.calledOnce( getDependenciesSpy );
  41. sinon.assert.calledWithExactly( getDependenciesSpy, JSON.dependencies );
  42. sinon.assert.notCalled( installSpy );
  43. } );
  44. } );