1- import { connect , StringCodec } from "nats" ;
1+ import { jetstreamManager } from "@nats-io/jetstream" ;
2+ import { connect } from "@nats-io/transport-node" ;
23import { NatsContainer } from "./nats-container" ;
34
45describe ( "NatsContainer" , { timeout : 180_000 } , ( ) => {
@@ -25,19 +26,18 @@ describe("NatsContainer", { timeout: 180_000 }, () => {
2526
2627 const container = await new NatsContainer ( ) . start ( ) ;
2728 const nc = await connect ( container . getConnectionOptions ( ) ) ;
28- const sc = StringCodec ( ) ;
2929
3030 //----------------
3131 const sub = nc . subscribe ( SUBJECT ) ;
3232 ( async ( ) => {
3333 for await ( const m of sub ) {
34- const actual : string = sc . decode ( m . data ) ;
34+ const actual : string = m . string ( ) ;
3535 expect ( actual ) . toEqual ( PAYLOAD ) ;
3636 }
3737 } ) ( ) . then ( ) ;
3838
3939 //----------------
40- nc . publish ( SUBJECT , sc . encode ( PAYLOAD ) ) ;
40+ nc . publish ( SUBJECT , PAYLOAD ) ;
4141
4242 //----------------
4343 await nc . drain ( ) ;
@@ -73,7 +73,7 @@ describe("NatsContainer", { timeout: 180_000 }, () => {
7373 const nc = await connect ( container . getConnectionOptions ( ) ) ;
7474
7575 // ensure JetStream is enabled, otherwise this will throw an error
76- await nc . jetstream ( ) . jetstreamManager ( ) ;
76+ await jetstreamManager ( nc ) ;
7777
7878 // close the connection
7979 await nc . close ( ) ;
@@ -90,7 +90,7 @@ describe("NatsContainer", { timeout: 180_000 }, () => {
9090 const nc = await connect ( container . getConnectionOptions ( ) ) ;
9191
9292 // ensure JetStream is not enabled, as this will throw an error
93- await expect ( nc . jetstream ( ) . jetstreamManager ( ) ) . rejects . toThrow ( "503 " ) ;
93+ await expect ( jetstreamManager ( nc ) ) . rejects . toThrow ( "jetstream is not enabled " ) ;
9494
9595 // close the connection
9696 await nc . close ( ) ;
0 commit comments