@@ -2,8 +2,8 @@ const HashMap = require('./hash-maps/hashmap');
22const TreeMap = require ( './tree-maps/tree-map' ) ;
33
44const mapImplementations = [
5- // Map,
6- // HashMap,
5+ Map ,
6+ HashMap ,
77 TreeMap ,
88] ;
99
@@ -72,11 +72,41 @@ mapImplementations.forEach((MapImplementation) => {
7272 } ) ;
7373
7474 it ( 'should update on delete' , ( ) => {
75- expect ( map . size ) . toBe ( 3 ) ;
76- expect ( map . has ( 1 ) ) . toBe ( true ) ;
7775 expect ( map . delete ( 1 ) ) . toBe ( true ) ;
7876 expect ( Array . from ( map . keys ( ) ) ) . toEqual ( [ 2 , 3 ] ) ;
7977 } ) ;
78+
79+ it ( 'should handle strings' , ( ) => {
80+ map . set ( 'uno' , 1 ) ;
81+ expect ( Array . from ( map . keys ( ) ) ) . toEqual ( [ 1 , 2 , 3 , 'uno' ] ) ;
82+ } ) ;
83+
84+ it ( 'should handle objects' , ( ) => {
85+ map . set ( { } , 1 ) ;
86+ expect ( Array . from ( map . keys ( ) ) ) . toEqual ( [ 1 , 2 , 3 , { } ] ) ;
87+ } ) ;
88+
89+ it ( 'should handle null' , ( ) => {
90+ map . set ( null , 1 ) ;
91+ expect ( [ ...map . keys ( ) ] . sort ( ) ) . toEqual ( [ 1 , 2 , 3 , null ] . sort ( ) ) ; // ignoring order
92+ } ) ;
93+ } ) ;
94+
95+ describe ( '#values' , ( ) => {
96+ beforeEach ( ( ) => {
97+ map . set ( 1 , 2 ) ;
98+ map . set ( 2 , 'dos' ) ;
99+ map . set ( 3 , 3 ) ;
100+ } ) ;
101+
102+ it ( 'should return all values' , ( ) => {
103+ expect ( Array . from ( map . values ( ) ) ) . toEqual ( [ 2 , 'dos' , 3 ] ) ;
104+ } ) ;
105+
106+ it ( 'should update on delete' , ( ) => {
107+ expect ( map . delete ( 1 ) ) . toBe ( true ) ;
108+ expect ( Array . from ( map . values ( ) ) ) . toEqual ( [ 'dos' , 3 ] ) ;
109+ } ) ;
80110 } ) ;
81111 } ) ;
82112} ) ;
0 commit comments