dev-init.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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( '../tasks/utils/tools' );
  9. describe( 'dev-init', () => {
  10. const initTask = require( '../tasks/utils/dev-init' );
  11. const ckeditor5Path = 'path/to/ckeditor5';
  12. const workspaceRoot = '..';
  13. const emptyFn = () => {};
  14. it( 'should get all ckedtior5- dependencies and execute dev-install on them', () => {
  15. const getDependenciesSpy = sinon.spy( tools, 'getCKEditorDependencies' );
  16. const installSpy = sinon.spy();
  17. const JSON = {
  18. dependencies: {
  19. 'ckeditor5-core': 'ckeditor/ckeditor5-code',
  20. 'non-ckeditor-plugin': '^2.0.0',
  21. 'ckeditor5-plugin-devtest': 'ckeditor/ckeditor5-plugin-devtest'
  22. }
  23. };
  24. const deps = JSON.dependencies;
  25. initTask( installSpy, ckeditor5Path, JSON, workspaceRoot, emptyFn );
  26. getDependenciesSpy.restore();
  27. sinon.assert.calledOnce( getDependenciesSpy );
  28. sinon.assert.calledWithExactly( getDependenciesSpy, deps );
  29. sinon.assert.calledTwice( installSpy );
  30. sinon.assert.calledWithExactly( installSpy.firstCall, ckeditor5Path, workspaceRoot, deps[ 'ckeditor5-core' ], emptyFn );
  31. sinon.assert.calledWithExactly( installSpy.secondCall, ckeditor5Path, workspaceRoot, deps[ 'ckeditor5-plugin-devtest' ], emptyFn );
  32. } );
  33. it( 'should not call dev-install if no ckedtior5- dependencies', () => {
  34. const getDependenciesSpy = sinon.spy( tools, 'getCKEditorDependencies' );
  35. const installSpy = sinon.spy();
  36. const JSON = {
  37. dependencies: {}
  38. };
  39. initTask( installSpy, ckeditor5Path, JSON, workspaceRoot, emptyFn );
  40. getDependenciesSpy.restore();
  41. sinon.assert.calledOnce( getDependenciesSpy );
  42. sinon.assert.calledWithExactly( getDependenciesSpy, JSON.dependencies );
  43. sinon.assert.notCalled( installSpy );
  44. } );
  45. } );