mapsequal.js 1.1 KB

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