1- import { describe , it , iit , expect } from 'test_lib/test_lib' ;
1+ import { describe , it , iit , ddescribe , expect } from 'test_lib/test_lib' ;
2+ import { MapWrapper } from 'facade/collection' ;
23
34class TestObj {
45 constructor ( prop ) {
@@ -7,12 +8,12 @@ class TestObj {
78}
89
910export function main ( ) {
10- describe ( " test_lib" , function ( ) {
11- describe ( " equality" , function ( ) {
12- it ( " should structurally compare objects" , function ( ) {
13- var expected = new TestObj ( new TestObj ( { " one" : [ 1 , 2 ] } ) ) ;
14- var actual = new TestObj ( new TestObj ( { " one" : [ 1 , 2 ] } ) ) ;
15- var falseActual = new TestObj ( new TestObj ( { " one" : [ 1 , 3 ] } ) ) ;
11+ describe ( ' test_lib' , ( ) => {
12+ describe ( ' equality' , ( ) => {
13+ it ( ' should structurally compare objects' , ( ) => {
14+ var expected = new TestObj ( new TestObj ( { ' one' : [ 1 , 2 ] } ) ) ;
15+ var actual = new TestObj ( new TestObj ( { ' one' : [ 1 , 2 ] } ) ) ;
16+ var falseActual = new TestObj ( new TestObj ( { ' one' : [ 1 , 3 ] } ) ) ;
1617
1718 expect ( actual ) . toEqual ( expected ) ;
1819 expect ( falseActual ) . not . toEqual ( expected ) ;
@@ -22,5 +23,28 @@ export function main() {
2223 expect ( [ { 'a' :'b' } ] ) . toEqual ( [ { 'a' :'b' } ] ) ;
2324 } ) ;
2425 } ) ;
26+
27+ describe ( 'toEqual for Maps' , ( ) => {
28+ it ( 'should detect equality for same reference' , ( ) => {
29+ var m1 = MapWrapper . createFromStringMap ( { 'a' : 1 } ) ;
30+ expect ( m1 ) . toEqual ( m1 ) ;
31+ } ) ;
32+
33+ it ( 'should detect equality for same content' , ( ) => {
34+ expect ( MapWrapper . createFromStringMap ( { 'a' : 1 } ) ) . toEqual ( MapWrapper . createFromStringMap ( { 'a' : 1 } ) ) ;
35+ } ) ;
36+
37+ it ( 'should detect missing entries' , ( ) => {
38+ expect ( MapWrapper . createFromStringMap ( { 'a' : 1 } ) ) . not . toEqual ( MapWrapper . createFromStringMap ( { } ) ) ;
39+ } ) ;
40+
41+ it ( 'should detect different values' , ( ) => {
42+ expect ( MapWrapper . createFromStringMap ( { 'a' : 1 } ) ) . not . toEqual ( MapWrapper . createFromStringMap ( { 'a' : 2 } ) ) ;
43+ } ) ;
44+
45+ it ( 'should detect additional entries' , ( ) => {
46+ expect ( MapWrapper . createFromStringMap ( { 'a' : 1 } ) ) . not . toEqual ( MapWrapper . createFromStringMap ( { 'a' : 1 , 'b' : 1 } ) ) ;
47+ } ) ;
48+ } ) ;
2549 } ) ;
2650}
0 commit comments