tasks.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* global describe, it, beforeEach, afterEach */
  6. 'use strict';
  7. const mockery = require( 'mockery' );
  8. const sinon = require( 'sinon' );
  9. describe( 'build-tasks', () => {
  10. let sandbox, tasks, rollupBundleMock, rollupBundleWriteMock;
  11. const config = {
  12. ROOT_DIR: '.',
  13. BUILD_DIR: 'build',
  14. BUNDLE_DIR: 'bundle'
  15. };
  16. beforeEach( () => {
  17. mockery.enable( {
  18. warnOnReplace: false,
  19. warnOnUnregistered: false
  20. } );
  21. sandbox = sinon.sandbox.create();
  22. rollupBundleWriteMock = sandbox.spy();
  23. rollupBundleMock = {
  24. write: rollupBundleWriteMock
  25. };
  26. mockery.registerMock( 'rollup', {
  27. rollup: () => {
  28. return {
  29. then: ( resolve ) => {
  30. resolve( rollupBundleMock );
  31. }
  32. };
  33. }
  34. } );
  35. tasks = require( '../../tasks/bundle/tasks' )( config );
  36. } );
  37. afterEach( () => {
  38. mockery.disable();
  39. sandbox.restore();
  40. } );
  41. describe( 'generate', () => {
  42. it( 'should use rollup to generate js bundle and save bundled file', () => {
  43. tasks.generate();
  44. sinon.assert.calledWithExactly( rollupBundleWriteMock, {
  45. dest: 'bundle/ckeditor.js',
  46. format: 'iife',
  47. moduleName: 'ClassicEditor'
  48. } );
  49. } );
  50. } );
  51. } );