tomap.js 1.0 KB

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