11import { expect } from "chai" ;
22
3- import { MemLocalHistory } from "./mem_local_history .js" ;
3+ import { LocalHistory } from "./local_history .js" ;
44import { ContentMessage } from "./message.js" ;
55import { HistoryStorage , PersistentStorage } from "./persistent_storage.js" ;
66
@@ -14,11 +14,11 @@ describe("PersistentStorage", () => {
1414
1515 expect ( persistentStorage ) . to . not . be . undefined ;
1616
17- const history1 = new MemLocalHistory ( { storage : persistentStorage } ) ;
17+ const history1 = new LocalHistory ( { storage : persistentStorage } ) ;
1818 history1 . push ( createMessage ( "msg-1" , 1 ) ) ;
1919 history1 . push ( createMessage ( "msg-2" , 2 ) ) ;
2020
21- const history2 = new MemLocalHistory ( { storage : persistentStorage } ) ;
21+ const history2 = new LocalHistory ( { storage : persistentStorage } ) ;
2222
2323 expect ( history2 . length ) . to . equal ( 2 ) ;
2424 expect ( history2 . slice ( 0 ) . map ( ( msg ) => msg . messageId ) ) . to . deep . equal ( [
@@ -28,13 +28,13 @@ describe("PersistentStorage", () => {
2828 } ) ;
2929
3030 it ( "uses in-memory only when no storage is provided" , ( ) => {
31- const history = new MemLocalHistory ( { maxSize : 100 } ) ;
31+ const history = new LocalHistory ( { maxSize : 100 } ) ;
3232 history . push ( createMessage ( "msg-3" , 3 ) ) ;
3333
3434 expect ( history . length ) . to . equal ( 1 ) ;
3535 expect ( history . slice ( 0 ) [ 0 ] . messageId ) . to . equal ( "msg-3" ) ;
3636
37- const history2 = new MemLocalHistory ( { maxSize : 100 } ) ;
37+ const history2 = new LocalHistory ( { maxSize : 100 } ) ;
3838 expect ( history2 . length ) . to . equal ( 0 ) ;
3939 } ) ;
4040
@@ -44,7 +44,7 @@ describe("PersistentStorage", () => {
4444 storage . setItem ( "waku:sds:history:channel-1" , "{ invalid json }" ) ;
4545
4646 const persistentStorage = PersistentStorage . create ( channelId , storage ) ;
47- const history = new MemLocalHistory ( { storage : persistentStorage } ) ;
47+ const history = new LocalHistory ( { storage : persistentStorage } ) ;
4848
4949 expect ( history . length ) . to . equal ( 0 ) ;
5050
@@ -58,8 +58,8 @@ describe("PersistentStorage", () => {
5858 const storage1 = PersistentStorage . create ( "channel-1" , storage ) ;
5959 const storage2 = PersistentStorage . create ( "channel-2" , storage ) ;
6060
61- const history1 = new MemLocalHistory ( { storage : storage1 } ) ;
62- const history2 = new MemLocalHistory ( { storage : storage2 } ) ;
61+ const history1 = new LocalHistory ( { storage : storage1 } ) ;
62+ const history2 = new LocalHistory ( { storage : storage2 } ) ;
6363
6464 history1 . push ( createMessage ( "msg-1" , 1 ) ) ;
6565 history2 . push ( createMessage ( "msg-2" , 2 ) ) ;
@@ -77,7 +77,7 @@ describe("PersistentStorage", () => {
7777 it ( "saves messages after each push" , ( ) => {
7878 const storage = new MemoryStorage ( ) ;
7979 const persistentStorage = PersistentStorage . create ( channelId , storage ) ;
80- const history = new MemLocalHistory ( { storage : persistentStorage } ) ;
80+ const history = new LocalHistory ( { storage : persistentStorage } ) ;
8181
8282 expect ( storage . getItem ( "waku:sds:history:channel-1" ) ) . to . be . null ;
8383
@@ -93,14 +93,14 @@ describe("PersistentStorage", () => {
9393 it ( "loads messages on initialization" , ( ) => {
9494 const storage = new MemoryStorage ( ) ;
9595 const persistentStorage1 = PersistentStorage . create ( channelId , storage ) ;
96- const history1 = new MemLocalHistory ( { storage : persistentStorage1 } ) ;
96+ const history1 = new LocalHistory ( { storage : persistentStorage1 } ) ;
9797
9898 history1 . push ( createMessage ( "msg-1" , 1 ) ) ;
9999 history1 . push ( createMessage ( "msg-2" , 2 ) ) ;
100100 history1 . push ( createMessage ( "msg-3" , 3 ) ) ;
101101
102102 const persistentStorage2 = PersistentStorage . create ( channelId , storage ) ;
103- const history2 = new MemLocalHistory ( { storage : persistentStorage2 } ) ;
103+ const history2 = new LocalHistory ( { storage : persistentStorage2 } ) ;
104104
105105 expect ( history2 . length ) . to . equal ( 3 ) ;
106106 expect ( history2 . slice ( 0 ) . map ( ( m ) => m . messageId ) ) . to . deep . equal ( [
@@ -134,11 +134,11 @@ describe("PersistentStorage", () => {
134134
135135 it ( "persists and restores messages with channelId" , ( ) => {
136136 const testChannelId = `test-${ Date . now ( ) } ` ;
137- const history1 = new MemLocalHistory ( { storage : testChannelId } ) ;
137+ const history1 = new LocalHistory ( { storage : testChannelId } ) ;
138138 history1 . push ( createMessage ( "msg-1" , 1 ) ) ;
139139 history1 . push ( createMessage ( "msg-2" , 2 ) ) ;
140140
141- const history2 = new MemLocalHistory ( { storage : testChannelId } ) ;
141+ const history2 = new LocalHistory ( { storage : testChannelId } ) ;
142142
143143 expect ( history2 . length ) . to . equal ( 2 ) ;
144144 expect ( history2 . slice ( 0 ) . map ( ( msg ) => msg . messageId ) ) . to . deep . equal ( [
@@ -152,11 +152,11 @@ describe("PersistentStorage", () => {
152152 it ( "auto-uses localStorage when channelId is provided" , ( ) => {
153153 const testChannelId = `auto-storage-${ Date . now ( ) } ` ;
154154
155- const history = new MemLocalHistory ( { storage : testChannelId } ) ;
155+ const history = new LocalHistory ( { storage : testChannelId } ) ;
156156 history . push ( createMessage ( "msg-auto-1" , 1 ) ) ;
157157 history . push ( createMessage ( "msg-auto-2" , 2 ) ) ;
158158
159- const history2 = new MemLocalHistory ( { storage : testChannelId } ) ;
159+ const history2 = new LocalHistory ( { storage : testChannelId } ) ;
160160 expect ( history2 . length ) . to . equal ( 2 ) ;
161161 expect ( history2 . slice ( 0 ) . map ( ( m ) => m . messageId ) ) . to . deep . equal ( [
162162 "msg-auto-1" ,
0 commit comments