@@ -11,20 +11,24 @@ import { InMemoryEventAlreadyExistsError } from './error';
1111const eventStoreId = 'eventStoreId' ;
1212
1313const aggregateIdMock1 = randomUUID ( ) ;
14+ const aggregate1InitialEventTimestamp = '2021-01-01T00:00:00.000Z' ;
1415const aggregateIdMock2 = randomUUID ( ) ;
16+ const aggregate2InitialEventTimestamp = '2022-01-01T00:00:00.000Z' ;
1517const aggregateIdMock3 = randomUUID ( ) ;
18+ const aggregate3InitialEventTimestamp = '2023-01-01T00:00:00.000Z' ;
1619const aggregateIdMock4 = randomUUID ( ) ;
20+ const aggregate4InitialEventTimestamp = '2024-01-01T00:00:00.000Z' ;
1721const eventMock1 = {
1822 aggregateId : aggregateIdMock1 ,
1923 version : 1 ,
2024 type : 'EVENT_TYPE' ,
21- timestamp : '2021-01-01T00:00:00.000Z' ,
25+ timestamp : aggregate1InitialEventTimestamp ,
2226} ;
2327const eventMock2 = {
2428 aggregateId : aggregateIdMock1 ,
2529 version : 2 ,
2630 type : 'EVENT_TYPE' ,
27- timestamp : '2022-01-01T00:00:00.000Z' ,
31+ timestamp : aggregate2InitialEventTimestamp ,
2832} ;
2933
3034describe ( 'in-memory storage adapter' , ( ) => {
@@ -135,7 +139,7 @@ describe('in-memory storage adapter', () => {
135139 aggregateId : aggregateIdMock2 ,
136140 version : 1 ,
137141 type : 'EVENT_TYPE' ,
138- timestamp : '2022-01-01T00:00:00.000Z' ,
142+ timestamp : aggregate2InitialEventTimestamp ,
139143 } ,
140144 { eventStoreId } ,
141145 ) ;
@@ -145,7 +149,16 @@ describe('in-memory storage adapter', () => {
145149 } ) ;
146150
147151 expect ( aggregateIds ) . toStrictEqual ( {
148- aggregateIds : [ aggregateIdMock1 , aggregateIdMock2 ] ,
152+ aggregateIds : [
153+ {
154+ aggregateId : aggregateIdMock1 ,
155+ initialEventTimestamp : aggregate1InitialEventTimestamp ,
156+ } ,
157+ {
158+ aggregateId : aggregateIdMock2 ,
159+ initialEventTimestamp : aggregate2InitialEventTimestamp ,
160+ } ,
161+ ] ,
149162 } ) ;
150163 } ) ;
151164
@@ -155,7 +168,7 @@ describe('in-memory storage adapter', () => {
155168 aggregateId : aggregateIdMock3 ,
156169 version : 1 ,
157170 type : 'EVENT_TYPE' ,
158- timestamp : '2023-01-01T00:00:00.000Z' ,
171+ timestamp : aggregate3InitialEventTimestamp ,
159172 } ,
160173 { eventStoreId } ,
161174 ) ;
@@ -165,7 +178,7 @@ describe('in-memory storage adapter', () => {
165178 aggregateId : aggregateIdMock4 ,
166179 version : 1 ,
167180 type : 'EVENT_TYPE' ,
168- timestamp : '2024-01-01T00:00:00.000Z' ,
181+ timestamp : aggregate4InitialEventTimestamp ,
169182 } ,
170183 { eventStoreId } ,
171184 ) ;
@@ -177,12 +190,22 @@ describe('in-memory storage adapter', () => {
177190 ) ;
178191
179192 expect ( aggregateIds ) . toStrictEqual ( [
180- aggregateIdMock1 ,
181- aggregateIdMock2 ,
193+ {
194+ aggregateId : aggregateIdMock1 ,
195+ initialEventTimestamp : aggregate1InitialEventTimestamp ,
196+ } ,
197+ {
198+ aggregateId : aggregateIdMock2 ,
199+ initialEventTimestamp : aggregate2InitialEventTimestamp ,
200+ } ,
182201 ] ) ;
202+
183203 expect ( JSON . parse ( nextPageToken as string ) ) . toStrictEqual ( {
184204 limit : 2 ,
185- lastEvaluatedKey : aggregateIdMock2 ,
205+ lastEvaluatedKey : {
206+ aggregateId : aggregateIdMock2 ,
207+ initialEventTimestamp : aggregate2InitialEventTimestamp ,
208+ } ,
186209 } ) ;
187210
188211 const lastAggregateIds = await eventStorageAdapter . listAggregateIds (
@@ -191,7 +214,16 @@ describe('in-memory storage adapter', () => {
191214 ) ;
192215
193216 expect ( lastAggregateIds ) . toStrictEqual ( {
194- aggregateIds : [ aggregateIdMock3 , aggregateIdMock4 ] ,
217+ aggregateIds : [
218+ {
219+ aggregateId : aggregateIdMock3 ,
220+ initialEventTimestamp : aggregate3InitialEventTimestamp ,
221+ } ,
222+ {
223+ aggregateId : aggregateIdMock4 ,
224+ initialEventTimestamp : aggregate4InitialEventTimestamp ,
225+ } ,
226+ ] ,
195227 } ) ;
196228 } ) ;
197229
@@ -207,13 +239,21 @@ describe('in-memory storage adapter', () => {
207239 } ,
208240 ) ;
209241
210- expect ( aggregateIds ) . toStrictEqual ( [ aggregateIdMock3 ] ) ;
242+ expect ( aggregateIds ) . toStrictEqual ( [
243+ {
244+ aggregateId : aggregateIdMock3 ,
245+ initialEventTimestamp : aggregate3InitialEventTimestamp ,
246+ } ,
247+ ] ) ;
211248 expect ( JSON . parse ( nextPageToken as string ) ) . toStrictEqual ( {
212249 limit : 1 ,
213250 initialEventAfter : '2021-02-01T00:00:00.000Z' ,
214251 initialEventBefore : '2023-02-01T00:00:00.000Z' ,
215252 reverse : true ,
216- lastEvaluatedKey : aggregateIdMock3 ,
253+ lastEvaluatedKey : {
254+ aggregateId : aggregateIdMock3 ,
255+ initialEventTimestamp : aggregate3InitialEventTimestamp ,
256+ } ,
217257 } ) ;
218258
219259 const { aggregateIds : lastAggregateIds , nextPageToken : noPageToken } =
@@ -223,7 +263,12 @@ describe('in-memory storage adapter', () => {
223263 ) ;
224264
225265 expect ( noPageToken ) . toBeUndefined ( ) ;
226- expect ( lastAggregateIds ) . toStrictEqual ( [ aggregateIdMock2 ] ) ;
266+ expect ( lastAggregateIds ) . toStrictEqual ( [
267+ {
268+ aggregateId : aggregateIdMock2 ,
269+ initialEventTimestamp : aggregate2InitialEventTimestamp ,
270+ } ,
271+ ] ) ;
227272 } ) ;
228273 } ) ;
229274
0 commit comments