@@ -5,8 +5,8 @@ import { KurrentDbContainer } from "./kurrentdb-container";
55const IMAGE = getImage ( __dirname ) ;
66
77describe . sequential ( "KurrentDbContainer" , { timeout : 240_000 } , ( ) => {
8- // startContainer {
98 it ( "should execute write and read" , async ( ) => {
9+ // startContainer {
1010 await using container = await new KurrentDbContainer ( IMAGE ) . start ( ) ;
1111
1212 const client = KurrentDBClient . connectionString ( container . getConnectionString ( ) ) ;
@@ -17,23 +17,17 @@ describe.sequential("KurrentDbContainer", { timeout: 240_000 }, () => {
1717 data :
{ email :
"[email protected] " } , 1818 type : "UserCreated" ,
1919 id : "28ab6bca-d9ae-418b-a1af-eb65dd653c38" ,
20- metadata : {
21- someMetadata : "bar" ,
22- } ,
20+ metadata : { someMetadata : "bar" } ,
2321 } ,
2422 ] ) ;
2523
2624 expect ( await consumeSteamingRead ( client . readStream ( "User-1" ) ) ) . toEqual ( [
2725 expect . objectContaining ( {
2826 event : expect . objectContaining ( {
29- data : {
30- 31- } ,
27+ data :
{ email :
"[email protected] " } , 3228 id : "28ab6bca-d9ae-418b-a1af-eb65dd653c38" ,
3329 isJson : true ,
34- metadata : {
35- someMetadata : "bar" ,
36- } ,
30+ metadata : { someMetadata : "bar" } ,
3731 revision : 0 ,
3832 streamId : "User-1" ,
3933 type : "UserCreated" ,
@@ -42,11 +36,19 @@ describe.sequential("KurrentDbContainer", { timeout: 240_000 }, () => {
4236 ] ) ;
4337
4438 await client . dispose ( ) ;
39+
40+ async function consumeSteamingRead ( read : AsyncIterableIterator < unknown > ) : Promise < unknown [ ] > {
41+ const events = [ ] ;
42+ for await ( const event of read ) {
43+ events . push ( event ) ;
44+ }
45+ return events ;
46+ }
47+ // }
4548 } ) ;
46- // }
4749
48- // usingStandardProjections {
4950 it ( "should use built-in projections" , async ( ) => {
51+ // usingStandardProjections {
5052 await using container = await new KurrentDbContainer ( IMAGE ) . start ( ) ;
5153 const client = KurrentDBClient . connectionString ( container . getConnectionString ( ) ) ;
5254
@@ -86,22 +88,12 @@ describe.sequential("KurrentDbContainer", { timeout: 240_000 }, () => {
8688 ) ;
8789 await stream . unsubscribe ( ) ;
8890 await client . dispose ( ) ;
91+
92+ async function getStreamFirstEvent ( stream : StreamSubscription ) : Promise < unknown > {
93+ for await ( const event of stream ) {
94+ return event ;
95+ }
96+ }
97+ // }
8998 } ) ;
90- // }
9199} ) ;
92-
93- async function consumeSteamingRead ( read : AsyncIterableIterator < unknown > ) : Promise < unknown [ ] > {
94- const events = [ ] ;
95-
96- for await ( const event of read ) {
97- events . push ( event ) ;
98- }
99-
100- return events ;
101- }
102-
103- async function getStreamFirstEvent ( stream : StreamSubscription ) : Promise < unknown > {
104- for await ( const event of stream ) {
105- return event ;
106- }
107- }
0 commit comments