8
0

utils.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals describe, it, expect */
  6. 'use strict';
  7. var modules = bender.amd.require( 'utils', 'utils-lodash' );
  8. describe( 'extend()', function() {
  9. // Properties of the subsequent objects should override properties of the preceding objects. This is critical for
  10. // CKEditor so we keep this test to ensure that Lo-Dash (or whatever) implements it in the way we need it.
  11. it( 'should extend by several params in the correct order', function() {
  12. var utils = modules.utils;
  13. var target = {
  14. a: 0,
  15. b: 0
  16. };
  17. var ext1 = {
  18. b: 1,
  19. c: 1
  20. };
  21. var ext2 = {
  22. c: 2,
  23. d: 2
  24. };
  25. utils.extend( target, ext1, ext2 );
  26. expect( target ).to.have.property( 'a' ).to.equal( 0 );
  27. expect( target ).to.have.property( 'b' ).to.equal( 1 );
  28. expect( target ).to.have.property( 'c' ).to.equal( 2 );
  29. expect( target ).to.have.property( 'd' ).to.equal( 2 );
  30. } );
  31. } );
  32. describe( 'Lo-Dash extensions', function() {
  33. // Ensures that the required Lo-Dash extensions are available in `utils`.
  34. it( 'should be exposed in utils', function() {
  35. var utils = modules.utils;
  36. var extensions = modules[ 'utils-lodash' ];
  37. extensions.forEach( function( extension ) {
  38. expect( utils ).to.have.property( extension ).to.not.be.undefined();
  39. } );
  40. } );
  41. } );