mapsequal.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 mapsEqual from '../src/mapsequal';
  6. describe( 'utils', () => {
  7. describe( 'mapsEqual', () => {
  8. let mapA, mapB;
  9. beforeEach( () => {
  10. mapA = new Map();
  11. mapB = new Map();
  12. } );
  13. it( 'should return true if maps have exactly same entries (order of adding does not matter)', () => {
  14. mapA.set( 'foo', 'bar' );
  15. mapA.set( 'abc', 'xyz' );
  16. mapB.set( 'abc', 'xyz' );
  17. mapB.set( 'foo', 'bar' );
  18. expect( mapsEqual( mapA, mapB ) ).to.be.true;
  19. } );
  20. it( 'should return false if maps size is not the same', () => {
  21. mapA.set( 'foo', 'bar' );
  22. mapA.set( 'abc', 'xyz' );
  23. mapB.set( 'abc', 'xyz' );
  24. expect( mapsEqual( mapA, mapB ) ).to.be.false;
  25. } );
  26. it( 'should return false if maps entries are not exactly the same', () => {
  27. mapA.set( 'foo', 'bar' );
  28. mapA.set( 'abc', 'xyz' );
  29. mapB.set( 'foo', 'bar' );
  30. mapB.set( 'xyz', 'abc' );
  31. expect( mapsEqual( mapA, mapB ) ).to.be.false;
  32. } );
  33. } );
  34. } );