tomap.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import toMap from '../src/tomap';
  6. import count from '../src/count';
  7. describe( 'utils', () => {
  8. describe( 'toMap', () => {
  9. it( 'should create map from object', () => {
  10. const map = toMap( { foo: 1, bar: 2 } );
  11. expect( count( map ) ).to.equal( 2 );
  12. expect( map.get( 'foo' ) ).to.equal( 1 );
  13. expect( map.get( 'bar' ) ).to.equal( 2 );
  14. } );
  15. it( 'should create map from iterator', () => {
  16. const map = toMap( [ [ 'foo', 1 ], [ 'bar', 2 ] ] );
  17. expect( count( map ) ).to.equal( 2 );
  18. expect( map.get( 'foo' ) ).to.equal( 1 );
  19. expect( map.get( 'bar' ) ).to.equal( 2 );
  20. } );
  21. it( 'should create map from another map', () => {
  22. const data = new Map( [ [ 'foo', 1 ], [ 'bar', 2 ] ] );
  23. const map = toMap( data );
  24. expect( count( map ) ).to.equal( 2 );
  25. expect( map.get( 'foo' ) ).to.equal( 1 );
  26. expect( map.get( 'bar' ) ).to.equal( 2 );
  27. } );
  28. } );
  29. } );