8
0
Pārlūkot izejas kodu

Add missing test cases for moapsEqual module

Oskar Wrobel 9 gadi atpakaļ
vecāks
revīzija
bf612194f3
1 mainītis faili ar 26 papildinājumiem un 3 dzēšanām
  1. 26 3
      packages/ckeditor5-utils/tests/mapsequal.js

+ 26 - 3
packages/ckeditor5-utils/tests/mapsequal.js

@@ -9,10 +9,14 @@ import mapsEqual from '/ckeditor5/utils/mapsequal.js';
 
 describe( 'utils', () => {
 	describe( 'mapsEqual', () => {
-		it( 'should return true if maps have exactly same entries (order of adding does not matter)', () => {
-			let mapA = new Map();
-			let mapB = new Map();
+		let mapA, mapB;
+
+		beforeEach( () => {
+			mapA = new Map();
+			mapB = new Map();
+		} );
 
+		it( 'should return true if maps have exactly same entries (order of adding does not matter)', () => {
 			mapA.set( 'foo', 'bar' );
 			mapA.set( 'abc', 'xyz' );
 
@@ -21,5 +25,24 @@ describe( 'utils', () => {
 
 			expect( mapsEqual( mapA, mapB ) ).to.be.true;
 		} );
+
+		it( 'should return false if maps size is not the same', () => {
+			mapA.set( 'foo', 'bar' );
+			mapA.set( 'abc', 'xyz' );
+
+			mapB.set( 'abc', 'xyz' );
+
+			expect( mapsEqual( mapA, mapB ) ).to.be.false;
+		} );
+
+		it( 'should return false if maps entries are not exactly the same', () => {
+			mapA.set( 'foo', 'bar' );
+			mapA.set( 'abc', 'xyz' );
+
+			mapB.set( 'foo', 'bar' );
+			mapB.set( 'xyz', 'abc' );
+
+			expect( mapsEqual( mapA, mapB ) ).to.be.false;
+		} );
 	} );
 } );