@@ -36,105 +36,106 @@ describe('LocalStorageStore', () => {
3636 localStorage . clear ( )
3737 } )
3838
39- it ( 'should get, set and remove items' , ( ) => {
40- store . set ( '1' , {
39+ it ( 'should get, set and remove items' , async ( ) => {
40+ await store . set ( '1' , {
4141 uuid : '1' ,
4242 timestamp : 1 ,
4343 value : 'first' ,
4444 } )
4545
46- expect ( store . get ( '1' ) ) . toEqual ( {
46+ expect ( await store . get ( '1' ) ) . toEqual ( {
4747 uuid : '1' ,
4848 timestamp : 1 ,
4949 value : 'first' ,
5050 } )
5151
52- store . set ( '1' , {
52+ await store . set ( '1' , {
5353 uuid : '1' ,
5454 timestamp : 2 ,
5555 value : 'second' ,
5656 } )
5757
58- expect ( store . get ( '1' ) ) . toEqual ( {
58+ expect ( await store . get ( '1' ) ) . toEqual ( {
5959 uuid : '1' ,
6060 timestamp : 2 ,
6161 value : 'second' ,
6262 } )
6363
64- expect ( store . values ( ) ) . toHaveLength ( 1 )
64+ expect ( await store . values ( ) ) . toHaveLength ( 1 )
6565
66- store . remove ( '1' )
66+ await store . remove ( '1' )
6767
68- expect ( store . values ( ) ) . toHaveLength ( 0 )
68+ expect ( await store . values ( ) ) . toHaveLength ( 0 )
6969 } )
7070
71- it ( 'should allow replacement of the entire map' , ( ) => {
72- store . set ( '1' , {
71+ it ( 'should allow replacement of the entire map' , async ( ) => {
72+ await store . set ( '1' , {
7373 uuid : '1' ,
7474 timestamp : 1 ,
7575 value : 'first' ,
7676 } )
7777
78- store . set ( '2' , {
78+ await store . set ( '2' , {
7979 uuid : '2' ,
8080 timestamp : 2 ,
8181 value : 'second' ,
8282 } )
8383
84- store . set ( '3' , {
84+ await store . set ( '3' , {
8585 uuid : '3' ,
8686 timestamp : 3 ,
8787 value : 'third' ,
8888 } )
8989
90- expect ( store . values ( ) ) . toEqual ( [
90+ expect ( await store . values ( ) ) . toEqual ( [
9191 { uuid : '1' , timestamp : 1 , value : 'first' } ,
9292 { uuid : '2' , timestamp : 2 , value : 'second' } ,
9393 { uuid : '3' , timestamp : 3 , value : 'third' } ,
9494 ] )
9595
9696 const newMap = { }
97- store . values ( ) . forEach ( item => {
97+ const theItems = await store . values ( )
98+ theItems . forEach ( item => {
9899 newMap [ item . uuid ] = {
99100 ...item ,
100101 value : 'new' ,
101102 }
102103 } )
103- store . replace ( newMap )
104+ await store . replace ( newMap )
104105
105- expect ( store . values ( ) ) . toEqual ( [
106+ expect ( await store . values ( ) ) . toEqual ( [
106107 { uuid : '1' , timestamp : 1 , value : 'new' } ,
107108 { uuid : '2' , timestamp : 2 , value : 'new' } ,
108109 { uuid : '3' , timestamp : 3 , value : 'new' } ,
109110 ] )
110111 } )
111112
112- it ( `shouldn't allow more than the configured maxValues, using timestamp to remove the oldest entries` , ( ) => {
113- store . set ( '2' , {
113+ it ( `shouldn't allow more than the configured maxValues, using timestamp to remove the oldest entries` , async ( ) => {
114+ await store . set ( '2' , {
114115 uuid : '2' ,
115116 timestamp : 2 ,
116117 value : 'second' ,
117118 } )
118119
119- store . set ( '3' , {
120+ await store . set ( '3' , {
120121 uuid : '3' ,
121122 timestamp : 3 ,
122123 value : 'third' ,
123124 } )
124125
125- store . set ( '1' , {
126+ await store . set ( '1' , {
126127 uuid : '1' ,
127128 timestamp : 1 ,
128129 value : 'first' ,
129130 } )
130131
131- store . set ( '4' , {
132+ await store . set ( '4' , {
132133 uuid : '4' ,
133134 timestamp : 4 ,
134135 value : 'fourth' ,
135136 } )
136137
137- expect ( store . values ( ) ) . toEqual ( [
138+ expect ( await store . values ( ) ) . toEqual ( [
138139 { uuid : '2' , timestamp : 2 , value : 'second' } ,
139140 { uuid : '3' , timestamp : 3 , value : 'third' } ,
140141 { uuid : '4' , timestamp : 4 , value : 'fourth' } ,
0 commit comments